我在这里有这个功能,无论何时轻敲标记,它都会设法执行操作。但我只想对某些标记起作用,比如数组中包含的标记
markers_array = [GMSMarkers]()
有没有办法让mapView函数只对这些特定的标记执行?
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
}
谢谢
答案 0 :(得分:2)
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.