I have troubles deleting leaflet marker after zoom in Leafletjs. Using the newest leaflet version (1.8) and Geoserver vector tiles (Countries point layer):
var pbfLayer1 = L.vectorGrid.protobuf(url1, vectorTileOptions1).addTo(map);
var vectorTileOptions1 = {
vectorTileLayerStyles: { pane: 'labelcity', interactive: true,
lander: function(properties, zoom) { var markerid = properties.id;
markerland[markerid] = L.marker([properties.lat, properties.lon], { icon: L.divIcon({ iconUrl: null, iconSize: [0, 0], iconAnchor: [0, 0], popupAnchor: [0, 0], html: properties.name_de, className: 'landerlabel' }) }).addTo(markerGroup); }
Trying to remove all the labels when zooming:
markerGroup.clearLayers();
Tried it with moveend, zoomstart, zoom and zoomend, but it doesn´t remove all the labels. Especially after zoom out multiple zooms. For example from Zoom 5 to Zoom 2 with mouse wheel. And mostly the marker outside of the viewport are still visible…
How can I fix this? Or is there still another way to label vector points in leaflet without creating a marker?
Thank you very much!