2012-04-16 90 views
0

我要讓點擊事件爲每個在谷歌複雜的多邊形多邊形的映射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 

感謝

回答

2

再創建兩個多邊形POLY 1和POLY 2和手柄單擊事件他們:

google.maps.event.addListener(poly1, 'click', function (e) { 
    .... 
}); 
google.maps.event.addListener(poly2, 'click', function (e) { 
    .... 
}); 
+0

本作事件所有複雜的多邊形不是在它 – 2012-04-16 17:37:57

+1

@ M.SH每一部分,你的意思「多邊形的一部分」是什麼? google.maps中沒有像「多邊形的一部分」。我說「然後創建兩個多邊形」 - 這意味着簡單地將複雜的多邊形分割爲較小的多邊形,這就是解決方案。 – TMS 2012-04-16 17:47:33

+0

@ M.SH,我只是翻了一番,也許現在更清楚了? – TMS 2012-04-16 17:48:37