xamarin-docs icon indicating copy to clipboard operation
xamarin-docs copied to clipboard

Problems with code examples

Open maf-soft opened this issue 2 years ago • 0 comments

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.

maf-soft avatar Oct 13 '21 21:10 maf-soft