Javascript 传单-标记复制、移除层、透明层仅隐藏标记

Javascript 传单-标记复制、移除层、透明层仅隐藏标记,javascript,angular,ionic-framework,leaflet,ionic4,Javascript,Angular,Ionic Framework,Leaflet,Ionic4,markerGroup:L.LayerGroup this.markerGroup.eachLayer(function (layer) { this.markerGroup.removeLayer(layer); }); this.markerGroup.clearLayers() removeLayer()和clearLayers()按照传单文档中的描述工作,但我想知道是否有办法完全从markerGroup变量中删除layer/marker/instance。即使清除/删除了标记,

markerGroup:L.LayerGroup

this.markerGroup.eachLayer(function (layer) {
    this.markerGroup.removeLayer(layer);
});
this.markerGroup.clearLayers()

removeLayer()和clearLayers()按照传单文档中的描述工作,但我想知道是否有办法完全从markerGroup变量中删除layer/marker/instance。即使清除/删除了标记,当调用“我的刷新”按钮时,它仍然在markerGroup变量中包含以前的标记,并再次添加相同的标记,从而复制它们。这是一个问题,因为这些标记的阴影相互重叠,最终变成100%不透明。以前有没有人有什么建议或遇到过这个问题

编辑:感谢@Falke Design的建议。不幸的是,map.removeLayer不适合我。希望下面的信息更有用:

refreshButton() {
    this.markerGroup = new L.LayerGroup;
    clearInterval(this.refreshTimer);
    this.dynamicLatLong = this.map.getCenter();
    this.dynamicZoom = this.map.getZoom();
    this.markerGroup.clearLayers();
    this.polygonGroup.clearLayers();
    this.map.removeLayer(this.markerGroup);
    this.getCurrentAzure();
    this.leafletMap();
}
getCurrentAzure()使用for循环获取每个实例的lat、lng等数据,并将其分配给名为marker的变量。每一个标记都将通过以下行添加到markerGroup:

this.markerGroup = L.layerGroup().addTo(this.map);
marker.addTo(this.markerGroup)

传单贴图()创建贴图并使用以下线条将标记组绘制到贴图上:

this.markerGroup = L.layerGroup().addTo(this.map);

你能分享更多的代码吗。您是否也尝试过从地图中删除图层<代码>地图。removeLayer(图层)
更新了我的帖子@Falker Design。再次感谢您的回复:)您的问题很可能存在于getCurrentAzure和/或传单映射功能的详细信息中。请确保共享足够的代码,以便人们能够复制您的问题。请共享更多代码。您是否也尝试过从地图中删除图层<代码>地图。removeLayer(图层)
更新了我的帖子@Falker Design。再次感谢您的回复:)您的问题很可能存在于getCurrentAzure和/或传单映射功能的详细信息中。请确保共享足够的代码,以便人们能够重现您的问题。