Javascript 单击firefox中未触发的事件(谷歌地图)
此代码在除firefox浏览器之外的所有浏览器中都能正常工作。 事件单击不起作用Javascript 单击firefox中未触发的事件(谷歌地图),javascript,google-maps,firefox,events,Javascript,Google Maps,Firefox,Events,此代码在除firefox浏览器之外的所有浏览器中都能正常工作。 事件单击不起作用 var marker = new RichMarker({ position: new google.maps.LatLng( _latitude, _longitude ), map: map, draggable: draggableMarker, content: markerContent, flat: true });
var marker = new RichMarker({
position: new google.maps.LatLng( _latitude, _longitude ),
map: map,
draggable: draggableMarker,
content: markerContent,
flat: true
});
google.maps.event.addListener(marker, "click", function(event) {
alert(this.position);
});
我怎样才能解决这个问题?Thx.问题似乎在第615行 在内部向标记添加单击侦听器时,单击标记内容时将触发单击事件。在上面的一行中,单击事件将仅为内容的包装器触发(当标记可拖动时发生) 您需要修改函数addDraggingListeners,将其设置为:
RichMarker.prototype.addDraggingListeners_ = function() {
var that = this;
this.draggingListeners_ = [
google.maps.event.addDomListener(window, 'mousemove', function(e) {
that.drag(e);
}, true),
google.maps.event.addDomListener(window, 'mouseup', function() {
that.stopDrag();
}, true)
];
};
谢谢这非常有帮助!
RichMarker.prototype.addDraggingListeners_ = function() {
var that = this;
this.draggingListeners_ = [
google.maps.event.addDomListener(window, 'mousemove', function(e) {
that.drag(e);
}, true),
google.maps.event.addDomListener(window, 'mouseup', function() {
that.stopDrag();
}, true)
];
};