How to remove the geoJSON data and update new?

2,577 views
Skip to first unread message

Abhiram Ampabathina

unread,
Feb 4, 2013, 11:47:02 AM2/4/13
to leafl...@googlegroups.com
Hello guys,
 I am new to leaflet . I am trying to use it. I tried the gejson thing. I get it well. But, the problem is i have to update the jsondata . That means i have to delete the current markers and add the new markers. If i just add the new json data, i will be over ridding the markers. So, i would like to know , how to clear (or) remove the markers on the map.  

The code i used is : 

var geojsonFeature = [{
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 39.75621]
    }
      },
      {
        "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 36.75621]
    }
}];
L.geoJson(geojsonFeature).addTo(map);   


I hope to get a solution to clear all the markers in the map. Thank you.

Bryan McBride

unread,
Feb 6, 2013, 2:01:33 PM2/6/13
to leafl...@googlegroups.com
Just call .clearLayers() on your geojson variable.

BRYAN
Reply all
Reply to author
Forward
0 new messages