Javascript 谷歌地图自定义覆盖视图绘制了好几次
我的自定义Google Map overlayview绘制了几次 我搜索了类似的问题,并在Java中找到了它们,而不是在Javascript中 这是我的密码:Javascript 谷歌地图自定义覆盖视图绘制了好几次,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我的自定义Google Map overlayview绘制了几次 我搜索了类似的问题,并在Java中找到了它们,而不是在Javascript中 这是我的密码: DraggableOverlay.prototype.onAdd = function () { var container = document.createElement('div'), that = this; if (typeof this.get('content').nodeName !==
DraggableOverlay.prototype.onAdd = function () {
var container = document.createElement('div'),
that = this;
if (typeof this.get('content').nodeName !== 'undefined') {
container.appendChild(this.get('content'));
} else {
if (typeof this.get('content') === 'string') {
container.innerHTML = this.get('content');
} else {
return;
}
}
container.style.position = 'absolute';
container.draggable = true;
google.maps.event.addDomListener(this.get('map').getDiv(),
'mouseleave',
function () {
google.maps.event.trigger(container, 'mouseup');
});
this.set('container', container)
if (!this.getPanes()) {
return;
}
this.getPanes().floatPane.appendChild(container);
}
DraggableOverlay.prototype.draw = function () {
if (!this.getProjection()) {
return;
}
var pos = this.getProjection().fromLatLngToDivPixel(this.get('position'));
if (!this.get('container')) {
return;
}
this.get('container').style.left = pos.x + 'px';
this.get('container').style.top = pos.y + 'px';
};
但我只画了一次。它是如何被画几次的
以前有人遇到过这个问题吗
谢谢。但我只画了一次……很难给出答案,创建一个类什么都不做,你如何使用这个类?(我猜)原始代码()不会产生重复。您好@Dr.Molle谢谢您的建议。我解决了这个问题,只需将每个自定义标记存储到一个数组中,并在最近删除它们。