我制作了一个谷歌地图,你可以使用绘图管理器绘制圆形/矩形,或使用自定义的“绘制圆形”和“绘制矩形”按钮,如下例所示 http://googlegeodevelopers.blogspot.com.au/2011/11/make-your-map-interactive-with-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>
答案 0 :(得分:2)
答案 1 :(得分:0)
我已回答了一个问题,其中绘制时的圆/多边形附有删除按钮(X标记)。单击它将删除它所附加的形状。
Drawing Circles / Polygons With Individual Delete Buttons in Google Maps API v3