I've a MKMapView that shows a route between two points. These points can change so I wanted the MapView to zoom in that it shows the complete route. I fixed it with this code:
_map.SetVisibleMapRect(_routeOverlay.BoundingMapRect, true);
Now I want some padding around the edges because the route is now very close to the edges of the screen. How can I add padding to the MapView?
PS. I got it working in native iOS Xcode with this code but I can't get it working with Xamarin and C#:
[self.mapView2 setVisibleMapRect:[_routeOverlay boundingMapRect] edgePadding:UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0) animated:YES];
I finally fixed it after a few errors. I just had to add UIEdgeInsets to my SetVisibleMapRect() like this:
_map.SetVisibleMapRect (_routeOverlay.BoundingMapRect, new UIEdgeInsets(20, 20, 20, 20), true);
Thanks @Jason for pointing me in the right direction.
SetVisibleMapRect ()有一个重载可以做到这一点:
public virtual void SetVisibleMapRect (MKMapRect mapRect, MonoTouch.UIKit.UIEdgeInsets edgePadding, bool animate)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.