How to hide and show markers in a Leaflet map using zoomend.

Example jsfiddle.

closed as off-topic by PolyGeo Apr 18 '16 at 21:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


You can remove a layer holding the markers, then you could turn them on again. Is that what you are thinking?update of your fiddle.

Just make sure to add each marker to the layer Group, not the map.

L.geoJson(geojsonFeature, {

    pointToLayer: function(feature, latlng){

        marker = L.marker(e.latlng, {

            title: "Resource Location",
            alt: "Resource Location",
            riseOnHover: true,
            draggable: true,

        }).bindPopup("<input type='button' value='Delete this marker' class='marker-delete-button'/>");

        marker.on("popupopen", onPopupOpen);

        return marker;
  • thanks for solution. But i need Hide and show with positioned markers in a Leaflet map using zoomend. Example link. Any idea? – codebrackets Apr 14 '16 at 8:49
  • I am not understanding your request. That seems like the original fiddle you started with. You want to turn a layer of markers on and off? You said turn it off with zoomend which is what I showed you. When do you want to turn it on. – timlohnes Apr 15 '16 at 15:47
  • Now i want to only display markers at the zoomed area. example link. Idea, or solution? – codebrackets Apr 18 '16 at 17:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.