Swift solution :
You can add identifier or any thing to a marker by setting a value for a key for the marker:
marker.setValue("20", forKey: "id")
and you can get it later using :
marker.value(forKey: "id")
Or
My way to do it is by create an extension for the GMSMarker and using the userData property to make the GMSMarker fits my need, for me I want to add each marker with instance of Branch class (map with markers for branches of some company) and this is the way that I did:
extension GMSMarker {
var branch: Branch {
set(branch) {
self.userData = branch
}
get {
return self.userData as! Branch
}
}
}
so when I set the marker property I set it like this:
marker.branch = someBranch
Isn't that clearer and more readable than marker.userData = someBranch ??