0

我想在谷歌地图 v3 ex 中为复杂多边形中的每个多边形制作点击事件:

var path1 = [new google.maps.LatLng(31.246599, 29.999199),
             new google.maps.LatLng(29.999199, 31.246599),
             new google.maps.LatLng(30.246599,28.999199)];
var path2 = [new google.maps.LatLng(31, 30),
             new google.maps.LatLng(29.999199, 31.246599),
             new google.maps.LatLng(30.246599,28.999199)];

poly = new google.maps.Polygon({
  paths: [path1, path2],
  strokeColor: "#FF0000",
  strokeOpacity: 0.8,
  strokeWeight: 3,
  fillColor: "#FF0000",
  fillOpacity: 0.35,
  map: map });


 // i want to make click event for a polygon that represents by path1 
 // and the other that represents by path2

谢谢

4

1 回答 1

2

然后创建两个多边形 poly1 和 poly2 并处理它们的点击事件:

google.maps.event.addListener(poly1, 'click', function (e) {
    ....
});
google.maps.event.addListener(poly2, 'click', function (e) {
    ....
});
于 2012-04-16T17:18:09.543 回答