如何将规则设置为drawingManager,用户可以在特定缩放后绘制多边形。 例如,用户必须达到缩放18,然后DrawingManager允许绘制多边形。
function DrawingTools() {
myDrawingManager = new google.maps.drawing.DrawingManager({
drawingMode: null,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP,
drawingModes: [
google.maps.drawing.OverlayType.POLYGON,
]
},
polygonOptions: {
draggable: true,
editable: true,
fillColor: '#cccccc',
fillOpacity: 0.5,
strokeColor: '#000000'
}
});
myDrawingManager.setMap(map);
}
谢谢
答案 0 :(得分:1)
在地图缩放级别更改时设置事件侦听器。
google.maps.event.addListener(map, 'zoom_changed', function() {
if (map.getZoom() >= 18) {
DrawingTools();
}
});