Reputation: 1839
I'm using this simple MyMarker
class
class MyMarker: GMSMarker {
var id: UInt32 = 0
}
so that my markers can also hold an additional numerical tag. When the user taps on my markers I call a segue
to open a new scene the content's of which are dynamic and drawn with respect to the MyMarker
's id
. I want to do something like:
func mapView(mapView: GMSMapView, didTapMarker marker: MyMarker) -> Bool {
some_global_variable = marker.id;
performSegueWithIdentifier("segue", sender: nil)
return true
}
the problem of course is that the GMSMapViewDelegate expects marker to be of type GMSMarker
.
How can I implement the behaviour I am after?
Upvotes: 3
Views: 654
Reputation: 72460
You need to type cast GMSMarker
to your custom marker in it's delegate method, don't change signature of GMSMapViewDelegate
methods.
func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {
if let myMarker = marker as? MyMarker {
some_global_variable = myMarker.id
performSegueWithIdentifier("segue", sender: nil)
}
return true
}
Upvotes: 5