0
我想封裝谷歌地圖多邊形(google.maps.Polygon)和MAP(google.maps.Map)成JavaScript對象和處理兩個多邊形和映射中的某些事件。下面是一些代碼包封物谷歌地圖V.3事件監聽對象的方法
function Landmark(map, polygon) {
this.map = map;
this.polygon = polygon;
// Add a listener for the click event
google.maps.event.addListener(this.map, 'click', this.addPoint);
google.maps.event.addListener(this.polygon, 'click', this.addPoint);
addPoint = function (event) {
alert("xxx");
}
}
我使用調用的函數:
var myLatLng = new google.maps.LatLng(24.886436490787712, -70.2685546875);
var myOptions = {
zoom: 5,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
polygonInTest = new google.maps.Polygon({
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35
});
polygonInTest.setMap(map);
var landmark = new Landmark(map, polygonInTest);
但是,當我觸發事件,通過點擊地圖,我從螢火蟲這個錯誤:
f.e is undefined
[Break On This Error] function de(a,b){var c,d=a.__e3_||{};i...n"+b]=c,c=new ce(a,b,c,3));return c};
任何人都可以指出我在哪裏做錯了,並提出一些建議?任何評論或幫助表示讚賞。
在此先感謝。