I've got this function here which manages to perform an operation whenever a marker is tapped. But I would only like this to work on certain markers, say markers that are contained in an array
markers_array = [GMSMarkers]()
Is there any way to have mapView function only perform on these specific markers?
func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {
if let marker = marker as? ChosenMarker {
if marker.touchEnabled == true {
// Have to show which one is selected too.
print("Hello")
let setAsHomeButton: SetAsHomeButtonView = SetAsHomeButtonView(marker: marker)
self.view.addSubview(setAsHomeButton)
self.setupSetAsHomeButton(setAsHomeButton)
} else {
}
}
return true
}
Thank you
You can create a GMSMarkers subclass with a boolean like touchEnabled and in mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker)
you cast the parameter " marker
" to your custom class. Finally you can check if the touchEnabled is enable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.