In a Leaflet map, it is possible to add features to a GeoJSON layer using the addData method:

L.geoJSON: Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format (you can alternatively add it later with addData method)

addData(data): Adds a GeoJSON object to the layer.

Is it possible to remove all features from the GeoJSON layer, without destroying the layer and recreating it?

1 Answer 1


It seems that GeoJSON extends FeatureGroup, which extends LayerGroup, which has a method clearLayers().

This means that jsonLayer.clearLayers() can be used to remove the features from a GeoJSON layer.


  • Hi, I see it is not a very new threat, but I can't solve a very similar problem - removing a geojson feature. Here is my code: <br/> > onClick: function() {map.removeLayer(mygeojson)} <br/> Am I missing a point? I would appriciate if you could help @Stephen Lead
    – Gamze
    Commented Apr 13, 2017 at 12:07
  • @Gamze you should post this as a new question Commented Apr 17, 2017 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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