i want to use icon that icon_image1 = 'hci.png' in folium

Question:

icon_image = 'hci.png'
icon = CustomIcon(
    icon_image,
    icon_size=(75, 95),
    icon_anchor=(10, 30),
)
from folium.plugins import MarkerCluster
import folium
from folium.features import CustomIcon

mm = folium.Map(
    location=[latitude, longitude],
    zoom_start=15
)

coords = sub_df[['Latitude', 'Longitude']]


marker_cluster = MarkerCluster().add_to(mm)

for lat, long in zip(coords['Latitude'], coords['Longitude']):
    folium.Marker([lat, long], icon=icon).add_to(marker_cluster)
mm

also i tried this code
this code is okay

but cant show ‘hci.png’icon

that icon is Company CI icon

It was my original question

I want to change to Marker purple star to that Company

import folium
import pandas as pd
df = pd.read_excel('p대리점.xlsx')enter code here


latitude = 37.58
longitude = 127.0


m = folium.Map(location=[latitude, longitude],
           zoom_start=11.5)


sub_df = df


from folium.plugins import MarkerCluster
m = folium.Map(
location=[latitude, longitude],
zoom_start=15
)

coords = sub_df[['Latitude', 'Longitude']]

marker_cluster = MarkerCluster().add_to(m)

for lat, long in zip(coords['Latitude'], coords['Longitude']):
folium.Marker([lat, long], 
icon=folium.Icon(color='purple',icon='star')).add_to(marker_cluster)
m

[1: https://i.stack.imgur.com/KzBGc.jpg][1]
1: https://i.stack.imgur.com/KzBGc.jpg

and i changed this code by answer but cant Clustering and Markis location also little different

https://i.stack.imgur.com/nE4TL.pnghttps://i.stack.imgur.com/nE4TL.png

Asked By: pyinfent

||

Answers:

I wasn’t able to replicate fully, but I am noticing that color argument of Icon needs to be a specific color. Are you giving the marker a color?

userWarning: color argument of Icon should be one of: {'red', 'cadetblue', 'purple', 'beige', 'darkred', 'darkgreen', 'blue', 'darkpurple', 'lightgray', 'lightred', 'lightblue', 'orange', 'green', 'white', 'lightgreen', 'pink', 'gray', 'black', 'darkblue'}.
  [latitude, longitude], icon=folium.Icon(icon_image1).add_to(marker_cluster)

Try something like this

folium.Marker(location=[coord[0], coord[1]], popup=coord[2], icon=folium.Icon(color="lightgreen", icon="info-sign")).add_to(marker_cluster)
Answered By: Initial Visuals

If you are applying an image from a local file to a custom icon and you want to make it a loop process, it seems that you need to put the custom icon process in the loop process. And it doesn’t seem to support clusters of custom icons. I wish I could provide specific evidence, but I have created test data and displayed the Stockoverflow.com logo.

from folium.plugins import MarkerCluster
import folium
from folium.features import CustomIcon
import pandas as pd
import random

sub_df = pd.DataFrame({'Latitude': [random.uniform(45.5, 46.5) for x in range(10)],
                       'Longitude': [random.uniform(-73.3, -74.3) for x in range(10)]})

latitude = sub_df['Latitude'].mean()
longitude = sub_df['Longitude'].mean()

mm = folium.Map(
    location=[latitude, longitude],
    zoom_start=10
)

coords = sub_df[['Latitude', 'Longitude']]

#marker_cluster = MarkerCluster().add_to(mm)

for lat, long in zip(coords['Latitude'], coords['Longitude']):
    icon_path = r"C:Usersdatapythonstackoverflowdatalogo-stackoverflow_resize.png"
    icon = CustomIcon(
        icon_image=icon_path,
        icon_size=(311, 62),
        icon_anchor=(10, 30),
    )
    marker = folium.Marker(location=[lat, long], icon=icon, popup="Mt. Hood Meadows")
    mm.add_child(marker)

mm

enter image description here

Answered By: r-beginners
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.