I have a MapView
in my app. And user can add an annotaion/pin to that MapView
. I works fine but I would like to know if it is possible to add new annotation design.
This is the new pin:
This is what my map shows:
This is my annotation code:
let annotaion = MKPointAnnotation()
this line adds my annotation to map:
self.myMap.addAnnotation(self.annotaion)
Thank you.
I believe @0ndre_ was looking for the default image, not to bring in his own custom image. The answer by @Franco_Meloni was incomplete. Here is how I got it to work.
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let pin = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: nil)
pin.canShowCallout = true
let button = UIButton(type: .detailDisclosure)
pin.rightCalloutAccessoryView = button
if annotation.isEqual(mapView.userLocation) {
return nil
}
return pin
}
The key is using MKMarkerAnnotationView to get the bigger marker. If you use MKPinAnnotationView you will see the smaller one appear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With