我需要在infoWindow
上打开customMarker
。
InfoWindow没有打开。 "单击"没有工作:
$google.maps.event.addDomListener(overlay, 'click', function () {
console.log("test");
iw.open(map, this);
});
这是我的代码:
$.getJSON(jsonShops, function(places) {
for (var i = 0, index = 0; i < places.shops.length; i++, index++) {
var bounds = new google.maps.LatLng(places.shops[i].lat, places.shops[i].lng);
var overlay = new MarkerSOverlay(bounds, alphabet.charAt(index), map);
var iw = new google.maps.InfoWindow({
content: "Simple",
position: bounds
});
google.maps.event.addDomListener(overlay, 'click', function () {
console.log("test");
iw.open(map, this);
});
}
答案 0 :(得分:1)
将addDomListener
更改为addListener
google.maps.event.addListener(overlay, 'click', function () {
console.log("test");
iw.open(map, this);
});
addListener
适用于google.maps对象(如标记),addDomListener
适用于DOM节点。