user19566
user19566

Reputation: 153

Disable Geosearch esri controls in leaflet

It is possible to disable the Geosearch esri controls in leaflet after the first geocode search?.When i run chrome console and i select the search geocode icon this is the code: <input class="geocoder-control-input leaflet-bar">, i have tried to disable using $('.geocoder-control-input leaflet-bar').attr('disabled', true); but doesn't work.

Thanks in advance.

Upvotes: 0

Views: 877

Answers (1)

iH8
iH8

Reputation: 28638

Somewhere in your code (which you didn't share) the control is being initialized and added to the map. Like this:

var geosearch = L.esri.Geocoding.geosearch(...).addTo(map);

Or something like this:

var geosearch = L.esri.Geocoding.geosearch(...);

map.addControl(geosearch);

If you don't need the control ever, you can just remove those lines. If you want to be able to add it later you can just remove the .addTo(map) or map.addControl(geosearch) parts. You can remove it once it added by using the removeControl method of L.Map In short it works like this:

var geosearch = L.esri.Geocoding.geosearch(...);

// Add control to the map
map.addControl(geosearch);

// Remove control from the map
map.removeControl(geosearch);

References:

Upvotes: 2

Related Questions