【发布时间】:2011-09-04 10:31:45
【问题描述】:
我有一条 Google Maps V3 折线。我可以检测整个多段线上的点击事件,但我可以对点击事件做更高级的事情吗?
我想做的是检测折线的哪一部分被点击,并在警报中显示。
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 地图中执行此操作吗?
谢谢!
【问题讨论】:
-
我can't even get the click event to fire,我正在尝试像你一样添加元素以及直接在折线上,我做错了什么?
标签: google-maps google-maps-api-3 polyline