我在Java EE应用程序中有一个Google地图,可以在其中使用DrawingManager添加标记:
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: initZoom,
center: {lat: initLat, lng: initLng},
mapTypeId: 'roadmap',
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.LEFT_BOTTOM
}
});
geocoder = new google.maps.Geocoder;
drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: null,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [ 'marker']
},
markerOptions: {
zIndex: 2,
draggable: true},
circleOptions: {
fillOpacity: 0.5,
strokeWeight: 1,
clickable: false,
editable: true,
zIndex: 1
},
polygonOptions: {zIndex: 1}
});
drawingManager.setMap(map);
drawingManager.addListener('polygoncomplete', polygonCompleteListener);
drawingManager.addListener('markercomplete', drawnMarkerListener);
在“ markercomplete”操作中,我为标记添加了侦听器:
marker.addListener('click', drawnMarkerRightClickListener);
然后在鼠标上单击以打开Primefaces上下文菜单:
var drawnMarkerRightClickListener = function (e) {
var point = getPixelLocation(e.latLng);
selectedMarker = this;
var menu =
$(PrimeFaces.escapeClientId('PFForm:drawnmarkercontextmenu')).css({
top: point.y + 'px',
left: point.x + 'px'
});
menu.show();
};
问题在于菜单一秒钟后消失。它仅在短时间内可见。在V3.31更新之前,它运行良好,因此可能与以下内容连接:
默认情况下,将前256个标记DOM标记设为,然后使后续标记成为平铺标记。当前默认为所有图块标记+
我尝试像这样在全局设置标记的侦听器:
google.maps.event.addListener(drawnmarker,'click',
drawnMarkerRightClickListener);
但是似乎没有任何效果。任何帮助或线索都表示赞赏。