我制作了一个谷歌地图,您可以在其中使用绘图管理器或使用自定义的“绘制圆”和“绘制矩形”按钮绘制圆/矩形,如 http://googlegeodevelopers.blogspot.com.au/2011/11/上的示例使您的地图与 shape.html 交互
但是在这个例子中,可以选择形状然后在我的版本中删除,这是不可能的;总是选择所有形状,我在文档中找不到任何东西?
我的代码:
<script type="text/javascript">
function drawCircle(){
console.log("Drawing Circle on Map");
var circleOptions = {
<!--draw the circle in the center of the viewport-->
center : (map.getCenter()),
radius : 1000000,
map: map,
editable: true,
clickable:true
};
circle = new google.maps.Circle(circleOptions);
return false;
}
function drawRectangle(){
console.log("Drawing Rectangle on Map");
var rectOptions = {
<!--draw the circle in the center of the viewport-->
bounds: map.getBounds(),
radius : 1000000,
map: map,
editable: true,
clickable:true
};
rectangle = new google.maps.Rectangle(rectOptions);
return false;
}
function showDrawingManager(){
var managerOptions = {
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: [google.maps.drawing.OverlayType.MARKER, google.maps.drawing.OverlayType.CIRCLE,google.maps.drawing.OverlayType.RECTANGLE]
},
markerOptions: {
editable: true
},
circleOptions: {
editable: true
},
rectangleOptions: {
editable : true
}
}
var drawingManager = new google.maps.drawing.DrawingManager(managerOptions);
drawingManager.setMap(map);
}
</script>