我有2个按钮(图像)。第一个将仅删除选定的形状(并且它可以工作)。第二个必须删除地图上的所有叠加(我不能理解它是如何做的)。
我确定这里的错误:
var line = e;
line.type = e.type;
但我没有任何想法如何做到这一点。 哪个变量存储折线数组?
谢谢!
function setSelection(shape) {
clearSelection();
selectedShape = shape;
shape.setEditable(true);
}
function deleteSelectedShape() {
if (selectedShape) {
selectedShape.setMap(null);
}
}
.......
function deleteAllShape(newPolygon) {
if (newPolygon) {
for (i in newPolygon) {
newPolygon[i].setMap(null);
}
newPolygon.length = 0;
}
}
..........
drawingManager = new google.maps.drawing.DrawingManager({
.......});
google.maps.event.addListener(drawingManager, 'overlaycomplete', function(e) {
if (e.type != google.maps.drawing.OverlayType.MARKER) {
var line = e;
line.type = e.type;
var newShape = e.overlay;
newShape.type = e.type;
google.maps.event.addListener(newShape, 'click', function() {
setSelection(newShape);
});
setSelection(newShape);
google.maps.event.addListener(line, 'polylinecomplete', function() {
deleteAllShape(line);
});
}
});