如何清除绘制的 Azure 地图形状



我正在尝试使用绘图工具栏在 Azure Map 上绘制形状,但此工具栏中没有删除图标。 我正在尝试编写 javascript 来删除选定的形状,但它不起作用,但是通过清除所有形状来工作。

这是我的js代码的一部分,用于清除所有形状:

var source = drawingManager.getSource();
source.clear();

你有没有尝试过这样的事情:

$(document).ready(function() {
$( "#clearPolyGonSelection" ).on( "click", function(event) {
drawingManager.setOptions({ mode: 'idle' });
drawingManager.getSource().clear();
});
});

使用一些像这样的 HTML:

<button type="button" class="btn btn-primary" id="clearPolyGonSelection">clear polygon</button>

希望它有效:https://social.msdn.microsoft.com/Forums/lync/en-US/0bf016aa-fd31-4dee-8946-5440afeef9d4/drawingtools-how-to-delete-shape-from-the-map-how-to-drawedit-circle-using-bing-8-api?forum=bingmapsajax

if(condition){

shapeName = null;
}

可能是在您的情况下

source = null;

获取要删除的形状,然后

drawingManager.getSource().remove(shape);

最新更新