I have layer(lote_ocupa) in control layers, when i launch application is disable but:
When I click on the map, even if the "lote_ocupa" layer is disabled, the identify function selects the feature, but that is wrong.
here is the part of the code:
var identifiedFeature;
mymap.on('click', function (e) {
if(identifiedFeature){
mymap.removeLayer(identifiedFeature);
}
lote_ocupa.identify().on(mymap).at(e.latlng).run(function(error, featureCollection){
identifiedFeature = new L.GeoJSON(featureCollection.features[0], {
style: function(){
return {
color: '#5C7DB8',
weight: 2
};
}
}).addTo(mymap);
});
});
How do fix this ?