在 Google 个地图中点击多段线

Polyline Tap in Google Maps

我想知道 Google 地图中绘制的多段线是否有点击侦听器。 marker的tap是这样的:

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

        return false
    }

折线有没有等价的功能?我相信 Google 网络版地图第 3 版,您可以像这样为多段线添加事件侦听器:

google.maps.event.addListener(elines[i], 'click', function()
        {
            lineClick(this);
        });

Thanks!

ios/swift也可以这样吗?

您可以使用 isTappable 属性 的 GMSPolyline。

isTappable

If this overlay should cause tap notifications.

polyline.isTappable = true

只要点击折线,就会调用 GMSMapViewDelegate 方法 didTapOverlay

func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
        //Write your code here
    }

有关详细信息,请参阅 https://developers.google.com/maps/documentation/ios-sdk/reference/protocol_g_m_s_map_view_delegate-p.html#a3a2bf2ff4481528f931183cb364c0f4b