Closed sangyh closed 6 years ago
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 :smile:
@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.
@ocefpaf can you please help more about mentioned plugin, how to install or add to a folium project?
I have made an example notebook, did you look at that?
Sent from my iPhone
On 17 Oct 2017, at 06:00, morteza3000 notifications@github.com<mailto:notifications@github.com> wrote:
@ocefpafhttps://github.com/ocefpaf can you please help more about mentioned plugin, how to install or add to a folium project?
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/python-visualization/folium/issues/464#issuecomment-337118188, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWaWQfyAZKB4K9WBUT_EoqJH5Sdwpwcfks5stDR3gaJpZM4JNCFm.
No I didn't, can you please give me the name of that example notebook?
Plugins-search.ipynb
I think it should be there, I’ll check on my laptop when I get a chance if not.
Sent from my iPhone
On 17 Oct 2017, at 14:35, morteza3000 notifications@github.com<mailto:notifications@github.com> wrote:
No I didn't, can you please give me the name of that example notebook?
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/python-visualization/folium/issues/464#issuecomment-337233170, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWaWQWK59yLpUrMDEsiuBqxKRufajPIPks5stK07gaJpZM4JNCFm.
I'll really appreciate if you can share it.
PR: https://github.com/python-visualization/folium/pull/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
I'm away from office with limited connection. I'll check it as soon as I get back.
On Oct 17, 2017 4:05 AM, "Andy Challis" notifications@github.com wrote:
I have made an example notebook, did you look at that?
Sent from my iPhone
On 17 Oct 2017, at 06:00, morteza3000 <notifications@github.com<mailto: notifications@github.com>> wrote:
@ocefpafhttps://github.com/ocefpaf can you please help more about mentioned plugin, how to install or add to a folium project?
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ python-visualization/folium/issues/464#issuecomment-337118188, or mute the threadhttps://github.com/notifications/unsubscribe- auth/AWaWQfyAZKB4K9WBUT_EoqJH5Sdwpwcfks5stDR3gaJpZM4JNCFm.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/python-visualization/folium/issues/464#issuecomment-337137889, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6BLy5N7qjJXD8NroHTO055n0ERNirMks5stFGxgaJpZM4JNCFm .
@ghandic Thanks a lot but I faced with below error when I wanted to run notebook.
AttributeError Traceback (most recent call last)
Did you pip install from my search-feature branch? It’s not been accepted into the master branch of Folium yet.
Sent from my iPhone
On 18 Oct 2017, at 05:54, morteza3000 notifications@github.com<mailto:notifications@github.com> wrote:
@ghandichttps://github.com/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'
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/python-visualization/folium/issues/464#issuecomment-337460144, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWaWQfVU5m1VVUKMtElcRinPjvmydO2Oks5stYRpgaJpZM4JNCFm.
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?
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.
for second command I got below error:
C:\Windows\system32>pip install git+https://github.com/ghandic/folium.git@search -features Collecting git+https://github.com/ghandic/folium.git@search-features Cloning https://github.com/ghandic/folium.git (to search-features) to c:\users \morteza.has\appdata\local\temp\pip-ktrr6c-build Error [Error 2] The system cannot find the file specified while executing comm and git clone -q https://github.com/ghandic/folium.git c:\users\morteza.has\appd ata\local\temp\pip-ktrr6c-build Cannot find command 'git'
Install git...
Thanks a lot, it works now. :)
import folium from folium import plugins
coordinates = [ [42.3581, -71.0636], [42.82995815, -74.78991444], [39.17929819, -78.56603306]]
m = folium.Map(location=[41.9, -97.3], zoom_start=4, tiles="cartodbpositron") my_Circle1 = folium.CircleMarker(location=[42.3581, -71.0636], radius= 6, popup=str("one"), color='red', fill_opacity=0.7) my_Circle2 = folium.CircleMarker(location=[42.82995815, -74.78991444], radius= 6, popup=str("two"), color='red', fill_opacity=0.7) my_Circle3 = folium.CircleMarker(location=[39.17929819, -78.56603306], radius= 6, popup=str("three"), color='red', fill_opacity=0.7) plugins.Search(coordinates, search_zoom=6, geom_type="Polygon").add_to(m)
m.add_child(my_Circle1) m.add_child(my_Circle2) m.add_child(my_Circle3)
m.save('example.html')
This is how it was meant to be done:
points = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "name": "one" }, "geometry": { "type": "Point", "coordinates": [-71.0636, 42.3581] } }, { "type": "Feature", "properties": { "name": "two" }, "geometry": { "type": "Point", "coordinates": [-74.78991444, 42.82995815] } }, { "type": "Feature", "properties": { "name": "three" }, "geometry": { "type": "Point", "coordinates": [-78.56603306, 39.17929819] } } ] }
m = folium.Map( location=[42.82995815, -74.78991444], tiles = 'cartodbpositron', zoom_start=4 )
plugins.Search(points, search_zoom=20, ).add_to(m)
m.save('example.html')
It needs a layer to search through and you haven't supplied it by just passing coordinates. This will be added in with assertations into the next commit - as well as being able to use GeoJsonCss to add popups and styling rather than the default marker - this would allow you to use a circle marker then
@morteza3000 I have implemented GeoJsonCss now, so re install folium as you did before if you want to use it
Here is your example with popups and a custom Icon:
points = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "name": "One" }, "geometry": { "type": "Point", "coordinates": [-71.0636, 42.3581] }, "style": { "icon": { "iconUrl": "http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png", "iconSize": [32, 32], "iconAnchor": [16, 16] } }, "popupTemplate": "{name}" }, { "type": "Feature", "properties": { "name": "Two" }, "geometry": { "type": "Point", "coordinates": [-74.78991444, 42.82995815] }, "style": { "icon": { "iconUrl": "http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png", "iconSize": [32, 32], "iconAnchor": [16, 16] } }, "popupTemplate": "{name}" }, { "type": "Feature", "properties": { "name": "Three" }, "geometry": { "type": "Point", "coordinates": [-78.56603306, 39.17929819] }, "style": { "icon": { "iconUrl": "http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png", "iconSize": [32, 32], "iconAnchor": [16, 16] } }, "popupTemplate": "{name}" } ] }
m = folium.Map( location=[42.82995815, -74.78991444], tiles = 'cartodbpositron', zoom_start=4 )
plugins.Search(points, search_zoom=20).add_to(m)
m.save('example.html')
I installed new one and it is working perfectly, Thanks.
@ghandic can you please help me with another issue? I want to have name as plain text instead of icon, is it possible?
It is, I don’t think it’s integrated within folium yet but you can hack around it by using an image with the text in it, might be better with a png since you can have a transparent background.
Sent from my iPhone
On 12 Nov 2017, at 06:24, Morteza Hasan Abadi notifications@github.com<mailto:notifications@github.com> wrote:
@ghandichttps://github.com/ghandic can you please help me with another issue? I want to have name as plain text instead of icon, is it possible?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/python-visualization/folium/issues/464#issuecomment-343716417, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWaWQYexUXm3YhFLhVjBCunZoLYiWCZCks5s1o8pgaJpZM4JNCFm.
Hi @ghandic, How can I install git? Can you help me?
Hi i could not run this
pip install git+https://github.com/ghandic/folium.git@search-features
can you send an updated link please
thxs
@HSAG-2018 pip install folium as it is now in the master branch :)
ok i see however i got this error: AttributeError: module 'folium.plugins' has no attribute 'Search' when using this command plugins.Search(en_sid, search_zoom=6, geom_type='Polygon').add_to(map) any idea what i have missed? thx
What version of folium are you using?
0.5.0
Ok that was last updated 4 months ago you can install from this git repo’s master branch, I’m on my phone atm so can’t check the pip install command
@ocefpaf how are we managing the Pypi repo?
pip install git+https://github.com/python-visualization/folium.git
still not working not sure if from server side or my laptop... C:\UseCase3>pip install git+https://github.com/python-visualization/folium.git Collecting git+https://github.com/python-visualization/folium.git Cloning https://github.com/python-visualization/folium.git to c:\users\h\appdata\local\temp\pip-iqccyg6z-build fatal: unable to access 'https://github.com/python-visualization/folium.git/': SSL certificate problem: unable to get local issuer certificate Command "git clone -q https://github.com/python-visualization/folium.git C:\Users\h\AppData\Local\Temp\pip-iqccyg6z-build" failed with error code 128 in None
Ok try cloning the repo first then run the setup.py
Sent from my iPhone
On 17 Jan 2018, at 20:19, HSAG-2018 notifications@github.com<mailto:notifications@github.com> wrote:
still not working not sure if from server side or my laptop... C:\UseCase3>pip install git+https://github.com/python-visualization/folium.git Collecting git+https://github.com/python-visualization/folium.git Cloning https://github.com/python-visualization/folium.git to c:\users\h\appdata\local\temp\pip-iqccyg6z-build fatal: unable to access 'https://github.com/python-visualization/folium.git/': SSL certificate problem: unable to get local issuer certificate Command "git clone -q https://github.com/python-visualization/folium.git C:\Users\h\AppData\Local\Temp\pip-iqccyg6z-build" failed with error code 128 in None
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/python-visualization/folium/issues/464#issuecomment-358431749, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWaWQQEvVWnYuptJ3nOiliaOHqOd9Opwks5tLlXggaJpZM4JNCFm.
the cloning does not work so i tried to download the zip save it locally then run setup.py but this has no effect...shld replacing the whole existing folium directory with the new dowloaded one work? thxs
@ocefpaf how are we managing the Pypi repo?
There will be a new release once I can allocate some time to review and merge the open PRs.
@ghandic Hello sorry to bother. I also want to add search functionality on a group of markers and display a pop up so I tried running the sample code with GeoJsonCss implemented which you provided above but it doesn't seem to be working. To be more specific, I can't get the pop ups to appear.
I've pip installed from the git (pip install git+https://github.com/python-visualization/folium.git) and am running on python 3.6.3.
Hope I can get it to work soon :) Thanks!
Hi @javaUtilScammer can you add your source code? I’ll take a look at this this morning if you can
Hi @ghandic , didn't expect you to reply so fast but big thank you :) I wanted to implement the search functionality on another map I made using Folium a while back but I can't get the popups to appear on a sample.
It's pretty much the code you commented a while back plus imports. Thanks!
import folium from folium import plugins from folium import GeoJson
points = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "name": "One" }, "geometry": { "type": "Point", "coordinates": [-71.0636, 42.3581] }, "style": { "icon": { "iconUrl": "http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png", "iconSize": [32, 32], "iconAnchor": [16, 16] } }, "popupTemplate": "{name}" }, { "type": "Feature", "properties": { "name": "Two" }, "geometry": { "type": "Point", "coordinates": [-74.78991444, 42.82995815] }, "style": { "icon": { "iconUrl": "http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png", "iconSize": [32, 32], "iconAnchor": [16, 16] } }, "popupTemplate": "{name}" }, { "type": "Feature", "properties": { "name": "Three" }, "geometry": { "type": "Point", "coordinates": [-78.56603306, 39.17929819] }, "style": { "icon": { "iconUrl": "http://downloadicons.net/sites/default/files/small-house-with-a-chimney-icon-70053.png", "iconSize": [32, 32], "iconAnchor": [16, 16] } }, "popupTemplate": "{name}" } ] }
m = folium.Map( location=[42.82995815, -74.78991444], tiles = 'cartodbpositron', zoom_start=4 )
plugins.Search(data=points, search_zoom=20,position="topright").add_to(m) m.save('example.html')
@javaUtilScammer the GeoJsonCss part has not been merged into master on this repo, I just had a look at my fork vs this repo. @ocefpaf was there some problems with the GeoJsonCSS?
@ocefpaf was there some problems with the GeoJsonCSS?
My time to finish reviewing it. I do recall some issues when testing against the notebook gallery, but I cannot get back to that this month :unamused:
No problem @ocefpaf I saw some of the modifications you did and it simplifies it a lot, I'm happy to test some of those notebooks out.
Meanwhile @javaUtilScammer if you really need this purely as an output and not for long term you could use my forked repo https://github.com/ghandic/folium.git
Check back soon and I'm sure we'll be a few steps closer to having this up and running!
No problem @ocefpaf I saw some of the modifications you did and it simplifies it a lot, I'm happy to test some of those notebooks out.
Our testing is a little time consuming, we need to run all the notebooks from example folder and inspect them visually. If you could do that and fix the remaining issues that would be awesome!
@ocefpaf Just found a great little package which speeds that up, called nbmerge
# cd into the project folder
pip install nbmerge
# Merges all of the notebooks into one inside examples/_merged.ipynb
nbmerge --recursive -i -p ".*" -o examples/_merged.ipynb
Meanwhile @javaUtilScammer if you really need this purely as an output and not for long term you could use my forked repo https://github.com/ghandic/folium.git
@ghandic will do that for now but will definitely come back when the merge is complete! Big thanks goes to you and @ocefpaf for the quick action :)
@ocefpaf
I spun up a docker container running jupyter notebook, cloned the repo and installed folium from your last commit hash on the pull request for #762
Then I merged all the notebooks and ran all cells, all of which seems to work perfectly. I haven't done any other testing than that, just checked the outputs and nothing errored
version: "2"
services:
jupyter-notebook:
build: .
image: challisa/folium-notebook
container_name: folium-notebook
ports:
- "8888:8888"
volumes:
- ~:/home/jovyan/work
entrypoint: start-notebook.sh --NotebookApp.token='' --NotebookApp.iopub_data_rate_limit=1000000000000000
FROM jupyter/minimal-notebook
USER root
# libav-tools for matplotlib anim
RUN apt-get update && \
apt-get install -y --no-install-recommends libav-tools && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Cartopy
RUN conda install --yes -c conda-forge cartopy
USER $NB_USER
RUN pip install \
'matplotlib' \
'mplleaflet' \
'geographiclib' \
'gpxpy' \
'altair' \
'vincent' \
'geopandas' \
'pandas' \
'widgetsnbextension' && \
# Activate ipywidgets extension in the environment that runs the notebook server
jupyter nbextension enable --py widgetsnbextension --sys-prefix
USER $NB_USER
@ghandic Hi Andy, am I right that the popup functionality has not yet been merged with master?
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')
@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.
I believe they have refactored the code since I made my pull request. Maybe check in the example notebooks?
Sent from my iPhone
On 6 Apr 2019, at 21:46, Morteza Hasan Abadi notifications@github.com<mailto:notifications@github.com> wrote:
@HSAG-2018https://github.com/HSAG-2018 pip install folium as it is now in the master branch :)
@ghandichttps://github.com/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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/python-visualization/folium/issues/464#issuecomment-480494235, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWaWQcqnduWjpewznBwxl6Hcc5Z96r69ks5veHsVgaJpZM4JNCFm.
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.