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?


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 Apr 13 '17 at 12:07
  • @Gamze you should post this as a new question – Stephen Lead Apr 17 '17 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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