Custom Pin/Annotation Icon is centered on Position, how to make it on top??

Alexander Blohmé 1 Reputation point
2022-11-26T18:33:37.843+00:00

I have a problem when adding a custom needle pin image, it will be placed in the CENTER of the Position coordinate, not the top so if I zoom out the bottom of the tip of the needle will go way off the real location of the pin, any idea on how to make it like the native pins?

       annotationView = new CustomMKAnnotationView(annotation, customPin.Name);      
              
                annotationView.Image = UIImage.FromFile(customPin.image);      
               

            annotationView.CalloutOffset = new CGPoint(0, 0);      
                  
            annotationView.LeftCalloutAccessoryView = new UIImageView(UIImage.FromFile(customPin.image));      
            annotationView.RightCalloutAccessoryView = UIButton.FromType(UIButtonType.DetailDisclosure);      
            ((CustomMKAnnotationView)annotationView).Name = customPin.Name;      
            //((CustomMKAnnotationView)annotationView).Url = customPin.Url;      

264451-img-01c20f64e9fe-1.jpeg

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
{count} votes