the following code will enable the creation of polygon on the the map .This works fine but previous geojson layer is also visible when new layer is added.
$http.get("./json/sf.geo.json").success(function(data, status) {
leafletData.getMap('lfdt').then(function(map){
var polyLayer = L.geoJson(data, {filter: layerFilter}).addTo(map);
function clear_polygon() {
map.removeLayer( polyLayer );
}
function layerFilter(feature) {
if (feature.properties.zip === $scope.code) return true;
}
map.fitBounds(polyLayer.getBounds(), {
padding: [40, 40]
});
});
I am having dropdown of zipcodes and i want to show selected zipcode boundaries on leaflet map. the problem is when user is selected another zipcode, new polygon is showing but the old one is also showing as you can see in the below image.
Can Anyone please help me where should i write removeLayers(). Please suggest me.