I have developed an application using leaflet JS, which loads the services from the ArcGIS server via REST API.

I want to put a search box to search by cities. Should I load a base map to be able to search? How should I configure the search box?


You can use leaflet-control-geocoder in order to do that, all you have to do is include it in your JS code.

var map = L.map('map').setView([0, 0], 2);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  • Should I load the base map for that? – Leeloo May 31 '18 at 8:58
  • No, you only need a leaflet map – Hicham Zouarhi May 31 '18 at 9:18
  • Does it work as Lat/long search? – Leeloo May 31 '18 at 12:13
  • @Leeloo yes it does support reverse geocoding by using the method reverse(<L.LatLng> location, <Number> scale, callback, context) – Hicham Zouarhi May 31 '18 at 13:22
  • Thank you. Could you show an example of usage? – Leeloo May 31 '18 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.