Hello
Is there any guidlines/functions on how to ensure a series is visible in a XamGeographicMap?
I have a GeographicPolylineSeries. When the form is loaded I want to zoom in on the series and make it is visible with a little margin.
Hi logimatic,
Unfortunately there is no zoom to functionality or 'view all' capability when it comes to a series that takes up little space in the map. If you are manually providing points to the polyline series then you should be able to calculate the min/max longitude and latitude from all those points and with the min/max you can update the maps WindowRect to encompass that rectangle. GetZoomFromGeographic will help you construct that new window rect.
// calculate the min/max longitude and latitudes of your polyline points var minLongitude = GetMinLongitude(); var maxLongitude = GetMaxLongitude(); var minLatitude = GetMinLatitude(); var maxLatitude = GetMaxLatitude(); // use the GetZoomFromGeographic method to generate a new WindowRect var rect = this.geoMap.GetZoomFromGeographic(new Point(minLongitude, minLatitude), new Point(maxLongitude, maxLatitude)); this.geoMap.WindowRect = rect;
Thanks.
var rect = mapControl.GetZoomFromGeographic(new Point(minLongtitude, maxLatitude), new Point(maxLongtitude, minLatitude));
... + a little offset worked.
mapControl.WindowRectMinWidth = 1/ Math.Pow(2, maxZoomLevel -1) did the trick.
I just discovered this broke another function I had on the Map.
I am using offline tiles and I want to stop the user from zooming if he reaches the max zoom level (which is 8, 9 or 10). I did that when I initialized the map:
mapControl.WindowRectMinWidth = mapControl.WindowsRect.Width / Math.Pow(2, maxZoomLevel -1)
It worked great. But after setting the new WindowRect I can now zoom further that max zoom level.
Is that because the Width of the WindowRect is changing?
Do you have another solution to set limits on the zoom level?