1

我已经有了这个功能,它可以管理每当点击标记时执行操作。但是,我只会这样对某些标记工作,说都包含在一个阵列GoogleMaps Swift点击标记

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 
} 

谢谢

+2

您可以使用像touchEnabled这样的布尔值和mapView(mapView:GMSMapView,didTapMarker标记:GMSMarker)创建一个GMSMarkers子类,并将参数“marker”投射到您的自定义类。最后,您可以检查是否启用了touchEnabled。 – Juan

+0

@JuanGarcia我会试试看!应该这样做,谢谢。 – tryingtolearn

+0

@JuanGarcia我相信我已经得到它的工作,因为它只弹出选定的标记,但有没有办法获得原始的didTapMarker功能?因为这个函数似乎覆盖了它。 – tryingtolearn

回答

2

您可以创建一个子类GMSMarkers与像touchEnabled并在图形页面的布尔(MapView类:GMSMapView中,didTapMarker标记:GMSMarker)你施放的参数 “标记” 您的自定义类。最后,您可以检查是否启用了touchEnabled。