Search code examples
iosgoogle-mapsinfowindowgoogle-maps-sdk-ios

Google Maps iOS didTapInfoWindowOfMarker not triggered when on top of other markers


I'm using the latest GoogleMaps-iOS v1.3 SDK.

I'm having trouble getting didTapInfoWindowOfMarker to trigger on info window taps, when there are multiple other markers just behind it. Instead, taps on the info window more often than not acts as if tapping a marker behind it instead (and opening a different info window).

In particular, on my map I have dozens and dozens of GMSMarkers very close to each other - close enough that any info window popup would cover multiple markers, even on the highest zoom levels.

Is there a way to force taps on the info window to be processed before taps on markers behind it?


Solution

  • For now, I found this to be the best workaround:

    https://github.com/ryanmaxwell/GoogleMapsCalloutView

    Basically, return a zero-sized UIView in -(UIView*)mapView:markerInfoWindow: so there's no visible "google maps infowindow", and use the opportunity to create and add a custom UIView on top of the MapView at the same time. In mapView:didChangeCameraPosition, the UIView can be moved to track the marker as the map is moved around.

    Edit: This also has the benefit that you can have real, interactive UIViews. (And the SMCalloutView looks much better than the default infoWindow in the googlemaps SDK, too)