Polyline Tap在Google地图中

时间:2016-09-28 03:14:02

标签: ios swift google-maps-sdk-ios

我想知道Google Map中绘制的折线是否有水龙头监听器。标记的点击是:

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

        return false
    }

折线是否有任何等效功能?我相信在谷歌地图版本3 for web中,您可以为折线添加事件监听器,如下所示:

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

Thanks!

这在ios / swift中也可以吗?

1 个答案:

答案 0 :(得分:3)

您可以使用GMSPolyline的void insert_after(Node* head, int oldKey, int newKey){ Node* currNode = NULL; Node* nextNode = NULL; Node* newNode = NULL; if (head == NULL) { return; } currNode = head; newNode->key = newKey; while (currNode != NULL) { if (currNode->key == oldKey) { // oldKey is anywhere but last node if (currNode->next != NULL) { nextNode = currNode->next; newNode->next = nextNode; currNode->next = newNode; break; } // oldKey is at the last node else { currNode->next = newNode; newNode->next = NULL; break; } } currNode = currNode->next; } } 属性。

  

isTappable

     

如果此叠加层应该导致点击通知。

isTappable

每当点击折线时,都会调用GMSMapViewDelegate方法didTapOverlay

polyline.isTappable = true

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