# Troubles deleting marker after zoom in Leaflet

**URL:** <https://devforum.zoom.us/t/troubles-deleting-marker-after-zoom-in-leaflet/75363>\
**Category:** Windows\
**Created:** [September 3, 2022, 10:31am UTC](https://devforum.zoom.us/t/troubles-deleting-marker-after-zoom-in-leaflet/75363 "2022-09-03T10:31:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![makeupideaz](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/makeupideaz/32/41064_2.png) [@makeupideaz](https://devforum.zoom.us/u/makeupideaz)\
**Post date:** [September 3, 2022, 10:31am UTC](https://devforum.zoom.us/t/troubles-deleting-marker-after-zoom-in-leaflet/75363/1 "2022-09-03T10:31:30Z")

</div>

I have troubles deleting leaflet marker after zoom in Leafletjs. Using the newest leaflet version (1.8) and Geoserver vector tiles (Countries point layer):

```auto
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:

```auto
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 v[i](https://www.epoxyadhesiveglue.com/)ewport 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!

---

<div class="post-metadata">

**Author:** ![j.schoenemeyer](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@j.schoenemeyer](https://devforum.zoom.us/u/j.schoenemeyer)\
**Post date:** [September 3, 2022, 4:17pm UTC](https://devforum.zoom.us/t/troubles-deleting-marker-after-zoom-in-leaflet/75363/2 "2022-09-03T16:17:23Z")

</div>

I think you are in the wrong forum

> **[Issues · Leaflet/Leaflet](https://github.com/Leaflet/Leaflet/issues)**
>
> 🍃 JavaScript library for mobile-friendly interactive maps 🇺🇦 - Issues · Leaflet/Leaflet

would make more sense

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [October 4, 2022, 2:17am UTC](https://devforum.zoom.us/t/troubles-deleting-marker-after-zoom-in-leaflet/75363/3 "2022-10-04T02:17:36Z")

</div>

Closed on October 4, 2022, 2:17am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
