How to add image as an icon in a marker with folium

Viewed 19

I'm creating a map in python with folium and I've added markers in it, the problem is that I'm trying to change the icon of the marker to a customized png file, can someone help me with this issue? I would appreciate it a lot.

1 Answers

To add an image as an icon in a marker, you can use the folium.Icon class.

Here is an example:

import folium

map = folium.Map(
    location=[45.372, -121.6972],
    zoom_start=12,
    tiles='Stamen Terrain'
)

tooltip = 'Click me!'

folium.Marker(
    [45.3288, -121.6625],
    popup='<strong>Mt. Hood Meadows</strong>',
    tooltip=tooltip
).add_to(map)

folium.Marker(
    [45.3311, -121.7113],
    popup='<strong>Timberline Lodge</strong>',
    tooltip=tooltip,
    icon=folium.Icon(icon='cloud')
).add_to(map)

map
Related