Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Xamarin Forms Maps - MapSpan Zoom Level

$
0
0

Hi,

I am struggling with the zoom levels of the MapSpan object. I have used Xamarin.Forms.Maps for the display and Geolocation to track a device. As the location of the device updates, the map is re-centered around the device's current location.

The problem is I want to keep the current level of zoom by performing:

    var zoomLat = _map.VisibleRegion == null ? 6.0 : _map.VisibleRegion.LatitudeDegrees;
        var zoomLon = _map.VisibleRegion == null ? 6.0 : _map.VisibleRegion.LongitudeDegrees;
        var zoomRad = _map.VisibleRegion == null ? 6.0 : _map.VisibleRegion.Radius.Miles;

//Method number one of re-centering the map with current level of zoom
_map.MoveToRegion(new MapSpan(_mapViewModel.UserPosition, zoomLat, zoomLon));

//Method number two of re-centering the map with current level of zoom
_map.MoveToRegion(MapSpan.FromCenterAndRadius(_mapViewModel.UserPosition, Distance.FromMiles(zoomRad)));

The problem however is that with both methods the zoom level is just slightly out causing the map to zoom out over time. Is the any method for keeping the zoom level fixed?

I can also not just specify a rudimentary zoom level as I want the user to be able to pinch and zoom on the map application.

Any help regarding this problem will truly be appreciated.


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>