我有一個Google Maps V3多段線。我可以檢測整個多段線上的點擊事件,但是我可以使用點擊事件做更高級的事情嗎?谷歌地圖折線:點擊折線部分並返回ID?
我想要做的是檢測折線的哪一部分已被點擊,並在警報中顯示。
routePath = new google.maps.Polyline({
path: routeCoordinates,
strokeColor: "#CC33FF",
strokeWeight: 3
});
routePath.setMap(map);
google.maps.event.addListener(routePath, 'click', function() {
alert(routePath);
// TODO: display which section of the polyline has been clicked?
});
有誰知道如何在Google Maps中做到這一點?
謝謝!