-1

I've a problem with the size of a custom MKAnnotationView. I set a custom image but when the zoom of the MKMapView change the size of the annotation don't. I lost the default behaviour of the annotation like disappear in term of the zoom, resizing etc.. Thanks for help.

My Custom Annotation :

class CustomPointAnnotation: MKPointAnnotation {
var pinCustomImageName:String!
var index : Int! }


func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

    let reuseIdentifier = "pin"
    var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseIdentifier)
    annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseIdentifier)

    annotationView?.canShowCallout = true;
    let customPointAnnotation = annotation as! CustomPointAnnotation

    var image = UIImage(named: customPointAnnotation.pinCustomImageName)
    annotationView?.image = image
    annotationView!.isEnabled = true
    annotationView!.canShowCallout = true
    return annotationView
    }

Edit : I just wanna my annotation view resize when I zoom in or out the map. And when I am far the annoatation disapear.

Mgheraie
  • 1
  • 2
  • Probable duplicate of: https://stackoverflow.com/questions/8286711/resize-mkannotationview-image-when-map-zooms-in-and-out – David Chopin Dec 23 '19 at 20:11
  • Does this answer your question? [Is it possible to customize cluster image in iOS 11?](https://stackoverflow.com/questions/47100598/is-it-possible-to-customize-cluster-image-in-ios-11) – Kosuke Ogawa Dec 23 '19 at 23:35
  • Unclear what you're asking? Annotations do not change size when you zoom in/out. Overlays do (they are drawings on the earth surface), but annotations don't (they are just map markers). – matt Dec 23 '19 at 23:59

1 Answers1

0

to make annotation disapear use displayPriority

 annotationView?.displayPriority = .defaultHigh

static let required: MKFeatureDisplayPriority A constant indicating that the item is required.

static let defaultHigh: MKFeatureDisplayPriority A constant indicating that the item's display priority is high.

static let defaultLow: MKFeatureDisplayPriority A constant indicating that the item's display priority is low. Apple documentation

Mgheraie
  • 1
  • 2