【问题标题】:GMSMarker has no addGestureRecognizor?GMSMarker 没有 addGestureRecognizor?
【发布时间】:2018-04-07 04:54:54
【问题描述】:

如何检测标记是否已被点击?

这是我的代码:

 let Meridian = GMSMarker()
        Meridian.position = CLLocationCoordinate2D(latitude: 5.654874, longitude: 100.5320142)
        Meridian.title = "Recycling Factory"
        Meridian.snippet = "Meridian World Sdn Bhd"


        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.showMeridianInfo))
        Meridian.addGestureRecognizer(tapGesture)//here is where I get the error


  @objc func showMeridianInfo (sender: UITapGestureRecognizer) {
        print("meradin")


    }

【问题讨论】:

    标签: swift xcode google-maps uigesturerecognizer


    【解决方案1】:

    您必须遵守GMSMapViewDelegate 并实施:

    func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {}
    

    在此功能中,您可以访问所选标记的详细信息,例如标题等。

    marker.title
    

    【讨论】:

      猜你喜欢
      • 2017-05-04
      • 2013-12-07
      • 1970-01-01
      • 2019-03-15
      • 1970-01-01
      • 1970-01-01
      • 2013-05-17
      • 2018-12-21
      • 2015-05-11
      相关资源
      最近更新 更多