Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I intercept touches on a marker in Google Maps SDK for iOS?

I am new to the Google Maps SDK for iOS. When a user clicks on a marker, instead of showing the default info window with a title and snippet, I would like to direct them somewhere else in my app (such as a modal view controller). I have searched through the header files and online and I can't seem to find anything relating to touch events on markers. Does anyone have suggestions or workarounds?

like image 304
user2105505 Avatar asked Feb 24 '13 22:02

user2105505


People also ask

How do I drag a marker on Google Maps in Swift?

By default, marker is not draggable. marker. draggable=YES; You have to press-and-hold on the marker before it will begin dragging.


1 Answers

I believe what you want is to add the delegate and override the didTapMarker method

/**
 * Called after a marker has been tapped.
 *
 * @param mapView The map view that was pressed.
 * @param marker The marker that was pressed.
 * @return YES if this delegate handled the tap event, which prevents the map
 *         from performing its default selection behavior, and NO if the map
 *         should continue with its default selection behavior.
 */
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(id<GMSMarker>)marker;
like image 128
John Avatar answered Sep 19 '22 14:09

John