Remove selected annotation from mapView by double click - ios

I need help regarding removing annotation by double click.
Once I click on any existing annotation on my map, how do I differentiate which annotation/pin selected (double click)?
or any other suggested/common way to delete pins from mapView?
thanks in advance!!

double tap gesture recognizer is reserved by map kit framework to zooming in map view by default, but you can suppress that by using "hittest" in custom "MKPinAnnotationView" class.
I prepeared an example to show how to make callout touchable in map view with "hittest".
you can achieve this problem with the same way as I can do for callouts.
Detect tap on title of callout

Related

Make mapbox annotations draggable as soon as they are added to the map

I have successfully managed to implement draggable annotations by using this link https://docs.mapbox.com/ios/maps/examples/draggable-views/. However, these annotations become draggable only after long pressing on them. I am looking for a solution wherein the annotations become draggable as soon as they are added to the map. Thanks a lot for helping :)
Ended up coming up with my own implementation to suit my needs. Heres how I went about it:-
Add the UIPanGestureRecognizer on the annotation view of the annotation that needs to be dragged.
In the gesture recognizer, convert the in-screen gesture location to real-world coordinates using the mapView.convert(point, mapView) method. Use these coordinates to update the location of the dragged coordinate
Use the started and the ended state property of the gesture recognizer to determine the start and end of the drag gesture.

iOS: How to offer directions from annotation view?

Basically what I'm wondering is how to offer the user an option to get directions in Maps from an annotation (like that little car icon inside of the annotation that opens up directions)
You can use left/right callout accessory view to add your icon and when you tap on it you can implement your direction logic.

Hiding button in annotation callout Swift

I am wondering how I can hide and show a button in an annotation callout?
I set up my annotation view to have a left and a right button, each doing a separate task. The user can add an annotation by selecting a location from a table or long press.
I want the left button to be accessible and the right button to be hidden when the annotation is added via selection from table and the left button to be hidden the the right button to be accessible when the annotation is added via long press.
I have the buttons in the callout working but I can't figure how how to hide/show them. Any help is much appreciated!
Don't use a generic MapAnnotation object. Create a custom object that conforms to the MKAnnotation protocol and give it an Enum property that has a different value if it's added from your table or from a long press.
In your viewForAnnotation method, cast the annotation object to your custom type and check the property before deciding which callouts to add. (You'll need special-case code for the user location, as always.)

iOS: how to detect double tap on marker in GoogleMaps

I using GoogleMaps.framework in my iOS app. I need detect double tap on marker to do some action.
I try to find some public method to do it, but I am not lucky. Have any way to do it?
By referring to the delegate functions provided by the google map you can detect the if a marker has been clicked on :)
Assuming the marker is a view, can you not add a UITapGestureRecognizer to it and then set the number of taps required to trigger the recognizer to two?

ios MapKit have annotation description visible on launch and not on tap

I am using map on my IOS application. I can see the annotation on my map, and when I tap on that there is the description, which I have set. My question is whether I can have this description visible when map first loads and not make the user tap on the annotation to view it?
is that possible?
Thanks.
use an overlay instead of an annotation

Resources