Consider the example in the following link for Folium: US Employment visualization per county.

The result looks like what you see below:

    enter image description here

I would like to add a search box to it to be able to search by city, and have the visualization zoom in and/or center around it. How can I go about adding such search box to it? Can I add this functionality perhaps in the HTML file?

  • 1
    what do you want to do when you find a city (e.g. zoom the map to that county, return statistics etc.?). Generally speaking, you will need to add html but also javascript.
    – toms
    Jan 17 '15 at 1:35
  • 2
    It helps if you can tell us what you've already tried, what the results were, and what you expected to happen instead.
    – BradHards
    Jan 17 '15 at 1:43
  • Is there a way of searching for addresses and restricting to a certain region, for example, western California only? Jan 10 '19 at 20:09

You could use the Leaflet search control. It allows you to insert a search widget on your map, search by place names around the world (see Nominatim example), and once a place is selected, zoom/center your map to that place location.

enter image description here

In the Leaflet search's GitHub website you find examples on how to add the control to your leaflet map.

  • is there another solution to search your data by fields ?
    – A.HADDAD
    Jul 22 '18 at 21:05
  • 1
    Can you be more specific? What do you mean? Search in your own data. This is possible. An example can be found here: labs.easyblog.it/maps/leaflet-search/examples/…
    – Stefan
    Aug 8 '18 at 10:00
  • I tried replicate this example but My JS don't make call to the backend. Do you have any thoughts what the problem can be? Apr 19 at 22:44

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.