xamarin-docs
xamarin-docs copied to clipboard
Problems with code examples
I tried to follow the instructions and had many problems on the way. Here are just some some hints I rembember what might be wrong. I can provide more details if someone wants to work on this...
CustomRenderer.iOS:
nativeMap.GetViewForAnnotation = GetViewForAnnotation;
seems wrong if you look at what base.OnElementChanged
already does - isn't it enough to override GetViewForAnnotation?
if (annotation is MKUserLocation)
doesn't work, maybe what we see in base.GetViewForAnnotation
is better, but that wasn't enough in my case, I had to use if (!(annotation is MKPointAnnotation)) return null
.
Do we really need the additional list of custom pins? The existing list could be used, and there is also an existing method to find a pin from an annotation:
Pin pin = GetPinForAnnotation(annotation) ?? throw new Exception("Pin not found");
And then, there was some weird behaviour until I always set all properties of the MK...AnnotationView, no matter if it was reused or created. Maybe this happend only in my case, I use clustering.
I am also unsure when the reuseIdentifier should be the same and when not.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 19aecf1c-11b6-6920-a37e-817458e52dd1
- Version Independent ID: af9cea8e-800f-c462-7efb-7f048235db3a
- Content: Customizing a Map Pin - Xamarin
- Content Source: docs/xamarin-forms/app-fundamentals/custom-renderer/map-pin.md
- Product: xamarin
- Technology: xamarin-forms
- GitHub Login: @davidbritch
- Microsoft Alias: dabritch