百度地图删除removeOverlay指定覆盖物
第一步,给每个需要做处理的覆盖物加个标识,可自定义其他变量名称与值
第二步,查看地图所有覆盖物,查找标识,进行处理
实例代码:
// 画线 var sy = new BMap.Symbol(BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW, { scale: 0.6, //图标缩放大小 strokeColor: "#fff", //设置矢量图标的线填充颜色 strokeWeight: "2" //设置线宽 }); var icons = new BMap.IconSequence(sy, "10", "30"); // 创建polyline对象 var pois = [ new BMap.Point(116.72537988063353, 23.3984551930871), new BMap.Point(116.72658361001649, 23.397796004502233), new BMap.Point(116.7268710677796, 23.39822302641697) ]; var polyline = new BMap.Polyline(pois, { enableEditing: false, //是否启用线编辑,默认为false enableClicking: true, //是否响应点击事件,默认为true icons: [icons], strokeWeight: "8", //折线的宽度,以像素为单位 strokeOpacity: 0.8, //折线的透明度,取值范围0 - 1 strokeColor: "#18a45b" //折线颜色 }); // 用来清除指定元素 polyline.name = 'line' this.map.addOverlay(polyline); //增加折线
// 清除指定线 var allOverlay = this.map.getOverlays(); allOverlay.map(item => { if(item.name === 'line') { this.map.removeOverlay(item) } })
相关推荐
Chenliaoyuan 2020-06-11
moyigg 2020-04-20
Chenliaoyuan 2020-04-14
startXUEBA 2018-03-24
88971730 2011-08-18
jackiebobo 2011-04-08
ccgsteel 2019-06-30
aSuncat 2018-03-24
<div class="panel-body" style="height: 300px; width: 100%; overflow: auto;" data-platform-scroll="&q
道北吴彦祖 2017-01-15
乔乔 2016-07-20
goodyatou 2016-03-27
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="icons/apple-touch-icon-114x114-precom
道北吴彦祖 2015-09-29
Pig00 2019-06-27
johncena 2014-12-05