question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with Folium search plugin (Data=marker_cluster)

See original GitHub issue

I get a couple of stuck when i use folium.plugins.Search(marker_cluster) ,the first one search bar is not respond when i try to searching the second customicon png and default marker appear at the same place. Screenshot how can i get rid off these default marker?. thanks!.

 import folium
 from folium import plugins
 from folium.plugins import Search

points = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "one",
'icons': 'C:\\Users\\avion\\Desktop\\pandas\\my project\\factory.png'
},
"geometry": {
"type": "Point",
"coordinates": [-71.0636, 42.3581]
}
},
{
"type": "Feature",
"properties": {
"name": "two",
'icons': 'C:\\Users\\avion\\Desktop\\pandas\\my project\\factory.png'
},
"geometry": {
"type": "Point",
"coordinates": [-74.78991444, 42.82995815]
}
},
{
"type": "Feature",
"properties": {
"name": "three",
'icons': 'C:\\Users\\avion\\Desktop\\pandas\\my project\\factory.png'
},
"geometry": {
"type": "Point",
"coordinates": [-78.56603306, 39.17929819]
}
}
]
}

m = folium.Map(
location=[42.82995815, -74.78991444],
tiles = 'cartodbpositron',
zoom_start=1
)

style_one = lambda x: {'fillColor': 'green'}
marker_cluster = folium.plugins.MarkerCluster(name = 'site location').add_to(m)
for feature in points['features']:
    lon, lat = feature['geometry']['coordinates']
    icon = feature['properties']['icons']
    name = feature['properties']['name']
    icon = folium.CustomIcon(icon_image = icon,
                                 icon_size = (30,35),
                                 icon_anchor = (0,0))
    marker =folium.Marker(location = [lat, lon] ,popup =(folium.Popup(str(name))), 
                                   tooltip = "<strong>"+str(name)+"</strong>",
                                     icon = icon).add_to(marker_cluster)
geojson_obj = folium.GeoJson(points, style_function=style_one).add_to(marker_cluster)
statesearch = Search(layer=marker_cluster,
                     geom_type='Point',
                     placeholder="Search",
                     collapsed=True,
                     search_label='name',
                     search_zoom=14,
                     position='topright'
                    ).add_to(m)

m.save('example.html')

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
Conengmocommented, Apr 30, 2019

I don’t really understand your issue. Please check out our example notebooks and take it from there.

These issues are meant for tracking bugs and new functionalities, if you need more help debugging your code than Stackoverflow is probably a better channel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python - Search Plugin of Folium give an error - Stack Overflow
I use folium.Search() in python.However ,The code returns an error when I run my code.How the fix this problem? import folium from folium...
Read more >
plugins — Folium 0.12.1 documentation - GitHub Pages
Wrap some of the most popular leaflet external plugins. ... False) – When set to True, plugin will be activated on map loading...
Read more >
Search plugin of Folium doesn't appear - GIS Stack Exchange
The issue is that, at best the search plugin doesn't appear and at worse my folium map isn't displayed. Does anyone have this...
Read more >
folium search - You.com | The AI Search Engine You Control
I'm trying to add search functionality to a map I'm generating in Python with Folium. I see there is a handy Search plugin...
Read more >
python-visualization/folium - Gitter
I'll also look at opening an issue on github. ... For #3 the closest I belive is the Search plugin but it would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found