title: Leaflet remove GeoJSON layer(s)
body: <p>I'm coloring areas on the map by creating GeoJSON layers in leaflet. First I create an empty layer:</p>
  
  <pre><code>var layerPostalcodes=L.geoJSON().addTo(map);
  </code></pre>
  
  <p>Then I create a geojson element containing the shape information and add it to the layer:</p>
  
  <pre><code>layerPostalcodes.addData(geojson);
  </code></pre>
  
  <p>This displays the areas on the map correctly. Now, onclick of a button I'd like to remove all the shapes from the map. This is not working. I've tried several approaches:</p>
  
  <pre><code>layerPostalcodes.clearLayers();
  </code></pre>
  
  <p>or via a LayerGroup, by adding the GeoJSON layer to it so I can use removeLayer(). But, this does not even display the shapes let alone remove them.</p>
  
  <pre><code>var layerGroup = new L.LayerGroup();
  layerGroup.addLayer(layerPostalcodes);
  layerGroup.addTo(map);
  layerGroup.removeLayer(layerPostalcodes);
  </code></pre>
  
  <p>What am I doing wrong?</p>