How to change the pin of a map?

AdrianGhiAdrianGhi USMember ✭✭
edited June 2018 in Xamarin.iOS

Following this example: https://github.com/mrdnote/XamarinClustererDemo, I'm making an map with annotations.

I have already defined the image for clusters:

But this pin I don't understand how I can change:

Is there possible to change the pin? Because if I change with:
annotationView.Image and I'm giving my image, the image from clusters will be changed, but not the pins... And is very frustrating because I've searched a lot and I'm missing something because I can achieve what I want.

Tagged:

Best Answer

  • AdrianGhiAdrianGhi US ✭✭
    edited June 2018 Accepted Answer

    Yes, it's possible:

    First I made a class which implements from MKMapViewDelegate and override GetViewForAnnotation method.

    if (annotation is BasicMapAnnotation annotationImage)
    {
    var annotation = new MKAnnotationView(annotationImage, reuseIdentifier);
    UIImage image = UIImage.FromBundle(imageName);
    annotationView.Image = image;
    return annotationView;
    }

    At the end, you assign the ClassDelegate to MapView.Delegate

    Tadam!

Answers

  • AdrianGhiAdrianGhi USMember ✭✭
    edited June 2018 Accepted Answer

    Yes, it's possible:

    First I made a class which implements from MKMapViewDelegate and override GetViewForAnnotation method.

    if (annotation is BasicMapAnnotation annotationImage)
    {
    var annotation = new MKAnnotationView(annotationImage, reuseIdentifier);
    UIImage image = UIImage.FromBundle(imageName);
    annotationView.Image = image;
    return annotationView;
    }

    At the end, you assign the ClassDelegate to MapView.Delegate

    Tadam!

Sign In or Register to comment.