1 回答
TA贡献1856条经验 获得超17个赞
我能够在(存档的)信息框库中找到解决方案:https : //github.com/googlemaps/v3-utility-library/blob/master/archive/infobox/src/infobox.js#L231
看起来我在第一次尝试时就很接近了,但应该设置 event.cancelBubble = true;
最终解决方案:
Popup.prototype.onAdd = function () {
this.getPanes().floatPane.appendChild(this.containerDiv);
// This handler allows right click events on anchor tags within the popup
var allowAnchorRightClicksHandler = function (e) {
if (e.target.nodeName === "A") {
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
}
};
this.contextListener_ = google.maps.event.addDomListener(this.containerDiv, "contextmenu", allowAnchorRightClicksHandler);
};
Popup.prototype.onRemove = function () {
if (this.contextListener_) {
google.maps.event.removeListener(this.contextListener_);
this.contextListener_ = null;
}
if (this.containerDiv.parentElement) {
this.containerDiv.parentElement.removeChild(this.containerDiv);
}
};
有关弹出代码的其余部分,请参阅https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/javascript/examples/overlay-popup
添加回答
举报