question

Nort-0044 avatar image
0 Votes"
Nort-0044 asked RobCaplan edited

Xamarin.Forms iOS Customizing a Map Zoom

When i do max zoom and open again the map as FlyoutPage i have exception.
Video Link


dotnet-csharpdotnet-xamarin
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Nort-0044

Could you show your code and clarify which line cause the error ?

It will be helpful if you provide us a basic , reproducible project to test .

1 Vote 1 ·

My excaption:
"[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at TestApp.iOS.CustomMapRenderer.GetCustomPin (MapKit.MKPointAnnotation annotation) [0x0001f] in C:\Users\Admin\source\repos\TestApp\TestApp\TestApp.iOS\CustomMapRenderer.cs:114 "

Code where was excaption:

 CustomPin GetCustomPin(MKPointAnnotation annotation)
             {
                 var position = new Position(annotation.Coordinate.Latitude, annotation.Coordinate.Longitude);
                 foreach (var pin in customPins)
                 {
                     if (pin.Position == position)
                     {
                         return pin;
                     }
                 }
                 return null;
             }


I try to do like this:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map-pin


0 Votes 0 ·

My code where i created pins(markers):
95957-screenshot-2.png


0 Votes 0 ·
screenshot-2.png (56.8 KiB)

My method "GetViewForAnnotation" in class "CustomMapRenderer : MapRenderer" in iOS project:
65cee97ac970fdb50e6d6.png


0 Votes 0 ·

Sorry, I test the sample and with your code but can't reproduce the crash .
Could you provide us a basic , reproducible project to test ?

0 Votes 0 ·

1 Answer

Nort-0044 avatar image
0 Votes"
Nort-0044 answered Nort-0044 edited

In addition to this error, my pins were constantly confused (displayed incorrectly), but i removed this line:

 if (annotationView == null)

In my method "GetViewForAnnotation" in class "CustomMapRenderer : MapRenderer" in iOS project:
Everything began to work for me much better

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.