Skip to content

Add Search Box on Folium map #464

Closed
Closed

Description

@sangyh

Can anybody point me towards how to add a Search box on Folium?
I know Leaflet has this functionality but couldn't find any documentation on Folium.
Thanks in advance.

Activity

  1. ocefpaf commented on Aug 25, 2017

    @ocefpaf
    Member

    There is no search box on folium. One could add a plugin for the https://github.com/stefanocudini/leaflet-search and implement it.

    PRs welcome 😄

  2. added
    feature request
    plugin
    on Aug 25, 2017
  3. ghandic commented on Oct 16, 2017

    @ghandic
    Contributor

    @sangyh

    I have started to work on the leaflet-search plugin, it is awaiting a Pull Request, if you're still interested in this plugin a peer review would be great.

  4. morteza3000 commented on Oct 17, 2017

    @morteza3000

    @ocefpaf
    can you please help more about mentioned plugin, how to install or add to a folium project?

  5. ghandic commented on Oct 17, 2017

    @ghandic
    Contributor
  6. morteza3000 commented on Oct 17, 2017

    @morteza3000

    No I didn't, can you please give me the name of that example notebook?

  7. ghandic commented on Oct 17, 2017

    @ghandic
    Contributor
  8. morteza3000 commented on Oct 17, 2017

    @morteza3000

    I'll really appreciate if you can share it.

  9. ghandic commented on Oct 17, 2017

    @ghandic
    Contributor

    PR: #747

    https://github.com/ghandic/folium/blob/search-features/examples/Plugins-Search.ipynb

    (all of the data is self contained in the notebook - this will be changed shortly. This search feature is on my feature-seach branch

  10. ocefpaf commented on Oct 17, 2017

    @ocefpaf
    Member
  11. morteza3000 commented on Oct 18, 2017

    @morteza3000

    @ghandic
    Thanks a lot but I faced with below error when I wanted to run notebook.


    AttributeError Traceback (most recent call last)
    in ()
    9 )
    10
    ---> 11 plugins.Search(states, search_zoom=6, geom_type="Polygon").add_to(m)
    12
    13 m.save(os.path.join('results', 'Plugins_search_polygon.html'))

    AttributeError: 'module' object has no attribute 'Search'

  12. ghandic commented on Oct 18, 2017

    @ghandic
    Contributor
  13. morteza3000 commented on Oct 18, 2017

    @morteza3000

    sorry I'm totally new to folium, I've just install folium by pip and add your search.py file to "C:\ProgramData\Anaconda2\Lib\site-packages\folium\plugins". is it write?
    can you help what to do step by step?

  14. ghandic commented on Oct 18, 2017

    @ghandic
    Contributor

    run this:

    pip uninstall -y folium
    pip install git+https://github.com/ghandic/folium.git@search-features

    You will then have the latest development that has not been merged into master.

  15. 35 remaining items

  16. ms77grz commented on Mar 28, 2019

    @ms77grz

    Hi guys! Can anyone help me with search function? How can I find a marker by typing "one" in searchbar?

    from folium import plugins, Map, Marker, FeatureGroup, Popup, LayerControl
    import webbrowser

    m = Map(location=[43.25, 45.83333 ], zoom_start=10, zoom_control=False)

    fg = FeatureGroup(name='VTK')

    g1 = plugins.FeatureGroupSubGroup(fg, 'FTTB')
    g2 = plugins.FeatureGroupSubGroup(fg, 'FTTH')
    g3 = plugins.FeatureGroupSubGroup(fg, 'GPON')
    Marker([43.119749, 45.562305], popup=Popup('one')).add_to(g1)
    Marker([43.143048, 45.534987], popup=Popup('two')).add_to(g2)
    Marker([43.131022, 45.546844], popup=Popup('three')).add_to(g3)
    m.add_child(fg)
    m.add_child(g1)
    m.add_child(g2)
    m.add_child(g3)

    m.add_child(plugins.Search(fg))
    m.add_child(LayerControl(collapsed=False))
    m.save('test_map2.html')
    webbrowser.open('test_map2.html')

  17. morteza3000 commented on Apr 6, 2019

    @morteza3000

    @HSAG-2018
    pip install folium
    as it is now in the master branch :)

    @ghandic , when I install it with (> pip install folium) below error appears for same examples.
    can you please help?

    AssertionError: Search can only index FeatureGroup, MarkerCluster, GeoJson, and TopoJson layers at this time.

  18. ghandic commented on Apr 6, 2019

    @ghandic
    Contributor
  19. morteza3000 commented on Apr 7, 2019

    @morteza3000

    Yes, your example notebooks also don't work with provided data.

  20. ghandic commented on Apr 7, 2019

    @ghandic
    Contributor
  21. Conengmo commented on Apr 7, 2019

    @Conengmo
    Member

    @morteza3000 please open a new issue for your problem and include:

    • a stand-alone code snippet that results in the error message
    • the full error message
    • your folium version: print(folium.__version__)
  22. morteza3000 commented on Apr 7, 2019

    @morteza3000

    @Conengmo , please be informed that below issue has been raised.
    Problem with Folium search plugin (loading Geojosn Data) #1125

  23. chillinshunsui commented on Mar 22, 2020

    @chillinshunsui

    Thanks a lot, it works now. :)

    image

    hey, can you share the code

  24. ghandic commented on Mar 22, 2020

    @ghandic
    Contributor
  25. GinoVillalpando commented on Apr 22, 2020

    @GinoVillalpando

    is there a search plugin that works for FastMarkerCluster? I can't use MarkerCluster because it hinders the load performance because I'm using over 11,000 markers.

  26. morteza3000 commented on Apr 23, 2020

    @morteza3000

    Check out the example notebooks https://github.com/python-visualization/folium/blob/master/examples/plugin-Search.ipynb

    @ghandic , How we can style points in your example?

    citygeo = folium.GeoJson(
    pop_ranked_cities,
    name='US Cities',
    tooltip=folium.GeoJsonTooltip(
    fields=['nameascii','pop_max'],
    aliases=['','Population Max'],
    localize=True)
    ).add_to(m)

    how to add style_function to this in order to change points color or use custom icon?

  27. f2daz commented on Jun 3, 2020

    @f2daz

    Hey everyone,

    as the docs say, the search plugin can index FeatureGroup, MarkerCluster, GeoJson and TopoJson layers.
    It only worked for me on GeoJson layers so far.

    Could you please provide an example for FeatureGroup or MarkerCluster without GeoJson?

    Thanks in advance ;)

  28. PhilippMDoerner commented on Jun 25, 2020

    @PhilippMDoerner

    Looking at the Search plugins python file, search is currently only implemented for GeoJson and TopoJson. I'm not entirely sure as to why the documentation states that it also implements the search for FeatureGroup and MarkerClusters. Maybe there were/are plans down the line for it (?)

  29. asemrbehat commented on Mar 14, 2021

    @asemrbehat

    Check out the example notebooks https://github.com/python-visualization/folium/blob/master/examples/plugin-Search.ipynb

    @ghandic , How we can style points in your example?

    citygeo = folium.GeoJson(
    pop_ranked_cities,
    name='US Cities',
    tooltip=folium.GeoJsonTooltip(
    fields=['nameascii','pop_max'],
    aliases=['','Population Max'],
    localize=True)
    ).add_to(m)

    how to add style_function to this in order to change points color or use custom icon?

    Hi, is there any way to do it by HTML ?
    I cant link the search box with the markers in order to search for them </>

  30. AtharvaShekatkar commented on Sep 20, 2023

    @AtharvaShekatkar

    @ghandic hey, could you help me with using the search plugin for FeatureGroup layers? I've not been able to find a working solution for that anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestplugin

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions