folium
folium copied to clipboard
Folium Search plugin doesn't work for FeatureGroup
Describe the bug The Folium Search plugin doesn't work for FeatureGroup. It simply returns nothing saying that "Feature is not found".
My code looks like this:
search_tool = Search( layer = or_cluster, search_label='post code', position='topright', search_zoom=20, geom_type='Point', popup_on_found=True ) map.add_child(search_tool)
Is it possible to sort it out? I use layer bound in Markerclusters.
Related issue:
https://github.com/python-visualization/folium/issues/1711
Could you include a fully working example? So that I can just run your code to reproduce your issue, without having to add anything. And please make it as minimal as possible.
import pandas as pd
import folium
map = folium.Map(location=[51.86762,0.8624],
tiles='OpenStreetMap',
zoom_start=8,
min_zoom=7,
max_zoom=19,
max_bounds=True,
control_scale=True,
prefer_canvas=True
)
df = pd.read_csv("or_geo.csv")
fo=FeatureGroup(name="Or",overlay = True)
or_cluster = MarkerCluster(name="General").add_to(map)
for i,row in df.iterrows():
lat =df.at[i, 'lat']
lng = df.at[i, 'lng']
sp = df.at[i, 'sp']
link = df.at[i, 'url']
stat = df.at[i,'status']
popup = folium.Popup(or_html, max_width=1000)
or_marker = folium.Marker(location=[lat,lng], tooltip='<strong>Job details</strong>', popup=popup, icon = folium.Icon(
color='blue', icon='glyphicon-calendar'))
or_cluster.add_child(or_marker)
This is the code. To be honest I have several layers such as this and would like to have this plugin functional for all of them on the same basis. Thank you in advance,
leaflet-search.min.js:17
Uncaught TypeError: Cannot read properties of undefined (reading 'properties')
This is what JavaScript console says
CSV file columns:
A - sp B - street C - post code D - status E - lat F - lng G - url