What marker is used in the Google Maps SDK ios?

I have a lot of markers in GMSMapView

. I want to know which marker is being used. I know there is a delegate - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker

. But my problem is that when I click any marker, I will show different information for each marker in infoWindow

. So, I have to know which marker is being used. How can i do this?

+3


source to share


2 answers


When you create a marker, set its property userData

to an instance of your own class that holds the marker data.



Then in didTapMarker

you can step out of the property userData

, apply it to your type, and then retrieve the data you want .

+4


source


You can set the accessibilityLabel property of the marker at the time of its creation from your data.



For example, you create markers from an array of objects, and then set the marker.accessibilityLabel of each marker as its position in your array, so when the user will use any marker, just find its accessibilityLabel and so find the data from the array at that position.

+2


source







All Articles