GMSMarker 没有 addGestureRecognizor 吗?

GMSMarker has no addGestureRecognizor?

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

这是我的代码:

 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")


    }

您必须遵守 GMSMapViewDelegate 并实施:

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

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

marker.title