I am doing queries toI'm filtering a geojson layer by user inputs,and works fine for the first query, and works fine for the first query, the problem is with the second so on. starting from the second query brings me the last layer plus the new one I already tried map.removeLayer(layer) any ideas on how can I get only the new queryfilter?,
function query(data) {
var input=null;
var user = null;
var input = document.getElementById("userInput").value;
departamentos.then(function(data) {
var alldeptos = L.geoJson(data);
var user = L.geoJson(data, {
filter: function (feature, layer) {
return feature.properties.nom_dpto == input;
},
});
var boyaca = L//console.geoJsonlog(data, {feature)
filter: function(feature, layer) {
return feature.properties.nom_dpto == "BOYACA";input;
},
});
$("#all").click(function() {
map.addLayer(alldeptos});
map.removeLayer(user});
map.removeLayer(boyaca)
});
$("#form""#allbus").click(function() {
console.log(map.hasLayer(user) + " ----") //first time returns false, second true
map.removeLayeraddLayer(alldeptos)
map.removeLayer(boyaca)
map.removeLayer(user)
map.addLayer(user});
console.log$(map"#form").hasLayerclick(caldasfunction() +{
" +++++")//true always
// map.removeLayer(user)
});
$("#boyaca").click(function(alldeptos) {
map.addLayer(boyaca)
map.removeLayer(alldeptosuser)
map.removeLayeraddLayer(user)
});
});
}