Open shubham039 opened 7 years ago
I got this solved, it needs icon to be initialised everytime you add a marker.
icon = folium.features.CustomIcon(icon_url,icon_size=(28, 30))
folium.Marker(location=[46.3288, -122.6625],icon=icon).add_to(map_osm)
map_osm
When icon have to be initialised everytime we got huge file. It's a bug.
I guess you're right @ninabel, do you want to look into this and open a PR? I'm thinking now we should let an element have multiple parents in a way, but render it only once. Or something.
Was this ever addressed in another issue? Because I notice the bug mentioned above by @ninabel still persists.
The bug is still persisting. It has not been solved yet. @hbarovertwo
I managed to solved this problem by initiliasing the custom icon within a for loop. Example below:
df = {'Lat': [22.50, 63.21, -13.21, 33.46],
'Lon': [43.91, -22.22, 77.11, 22.11],
'Color': ['red', 'yellow', 'orange', 'blue']
}
data = pd.DataFrame(df)
world = folium.Map(
zoom_start=2
)
x = data[['Lat', 'Lon', 'Color']].copy()
for index, row in x.iterrows():
pushpin = folium.features.CustomIcon('/content/drive/My Drive/Colab Notebooks/pushpin.png', icon_size=(30,30))
folium.Marker([row['Lat'], row['Lon']],
icon=pushpin,
popup=row['Color'],
).add_to(world)
world
Is this issue fix or is there a good work-around that does not load redundant copies of the same image, thus slowing the server?
I am creating a Custom Icon in folium, and displaying it on a map, but when i try to add another coordinate with the same Icon, it fails.
Now adding another location with the same icon
[The map_osm points to new location with its default icon, and the previous pin is removed.]
Expected Output should have been two map pins with the same icon.
folium.__version__
= '0.5.0'