Hi,
It seems I’m having a bit of a problem with the ZoomTo() method on the AndroidEdition.MapView.
My app uses whatever location provider’s available to set the preliminary position of the map, also setting a scale. I’m using ZoomTo(RectableShape) for this, and it seems to be working nicely (located in onStart).
When the GPS kicks in sending location updates, I want to just set just the map center, and keep the current scale. I use ZoomTo(PointShape) to accomplish this (in OnLocationChanged).
However, it seems like the map scale gets reset (by ZoomTo) to the one provided by the preliminary position every time the GPS sends a new location, even though I only provide a position. Is this true ?
1. In the WebEdition one can both fetch the current scale and set it with ZoomTo(), but this doesn’t seem to be working in AndroidEdition. I’m not familiar with DesktopEdition, which I assume is most similar to AndroidEdition.
2. How can I accomplish setting just a new MapView map center in AndroidEdition ?
Cheers
Lars
MapView - ZoomTo same scale?
Ah,
I just located the alternative method CenterAt(), and it does the job I want.
Cheers
Lars
Hi Lars,
There are some difference between “ZoomTo” and “CenterAt”.
“ZoomTo” methods zooms current map’s viewport to a specific shape. So the scale will change as well to match the bounding box of the shape. If it is a PointShape, we will set a minimum scale to zoom, just avoid to zoom too deep.
“CenterAt” is working in a different way. It always maintains current scale, even we pass a shape, we only use its center to locate the new extent. So CenterAt should work for your case.
To sync with WebEdition, we added a new overload of ZoomTo method as following to center the map with a specific scale. We will update a new version few days later. Please use the attached extension method temporary if you need to use “ZoomTo” method.public void ZoomTo(PointShape center, double scale)
Thanks and feel free to let me know if you have more queries.
Howard
Extensions.cs.txt (1.76 KB)