Search code examples
c#iosdictionaryxamarin.iosscale

How to add zoom in and zoom out button functionality for changing scale of map in xamarin.ios?


I already added two buttons in my c# program using storyboard, but I cannot found any property of map that can change the scale of current showing map.

Is there anything in Xamarin ios application that can change the scale of the map by using button like zoom in and zoom out?


Solution

  • CLLocationCoordinate2D coords = map.Region.Center;
    var degrees = MilesToLatitudeDegrees(map.Region.Span.LatitudeDelta / 2);
    MKCoordinateSpan span = new MKCoordinateSpan(degrees, longitudeDelta: map.Region.Span.LongitudeDelta / 2);
    map.Region = new MKCoordinateRegion(coords, span);
    

    Adding the above code in zoom button action will work as expected