0

Googleマップv3の複雑なポリゴン内のポリゴンごとにクリックイベントを作りたい例:

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

次に、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 に答える