I have many markers in GMSMapView
. I want to know which marker is tapped.
I know that there is - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
delegate. But my problem is when i tap any marker, i will show different information for every marker in infoWindow
. So, i must know which marker is tapped.How can i do this?
When you create the marker, set its userData
property to an instance of your own class which stores data about the marker.
Then in didTapMarker
, you can get out the userData
property, cast it to your own type, and then extract the details you need.
You can set the accessibilityLabel property of marker during its creation from your data.
For example you are creating the markers from an array of objects then set the marker.accessibilityLabel of each marker as its position in your array so when user is going to tap on any marker, just find its accessibilityLabel and so find the data from array at this position.
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