|
| 1 | +import folium |
| 2 | + |
| 3 | +# Library of Congress coordinates (latitude, longitude) |
| 4 | +loc_coordinates = (38.8886, -77.0047) |
| 5 | + |
| 6 | +# Create a Folium map centered around the Library of Congress |
| 7 | +m = folium.Map(tiles=None, location=loc_coordinates, zoom_start=15) |
| 8 | + |
| 9 | +# Define the DivIcon with the custom icon. This variable can be used in one marker successfully, but will fail if we use it in two markers. |
| 10 | + |
| 11 | + |
| 12 | +svg = """ |
| 13 | +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="35" |
| 14 | +width="35"> |
| 15 | +<path d="M12 |
| 16 | +21.5C10.65 20.65 8.2 20 6.5 20C4.85 20 3.15 20.3 1.75 21.05C1.65 21.1 1.6 21.1 |
| 17 | +1.5 21.1C1.25 21.1 1 20.85 1 20.6V6C1.6 5.55 2.25 5.25 3 5C4.11 4.65 5.33 4.5 |
| 18 | +6.5 4.5C8.45 4.5 10.55 4.9 12 6C13.45 4.9 15.55 4.5 17.5 4.5C18.67 4.5 19.89 |
| 19 | +4.65 21 5C21.75 5.25 22.4 5.55 23 6V20.6C23 20.85 22.75 21.1 22.5 21.1C22.4 |
| 20 | +21.1 22.35 21.1 22.25 21.05C20.85 20.3 19.15 20 17.5 20C15.8 20 13.35 20.65 12 |
| 21 | +21.5M11 7.5C9.64 6.9 7.84 6.5 6.5 6.5C5.3 6.5 4.1 6.65 3 7V18.5C4.1 18.15 5.3 |
| 22 | +18 6.5 18C7.84 18 9.64 18.4 11 19V7.5M13 19C14.36 18.4 16.16 18 17.5 18C18.7 18 |
| 23 | +19.9 18.15 21 18.5V7C19.9 6.65 18.7 6.5 17.5 6.5C16.16 6.5 14.36 6.9 13 |
| 24 | +7.5V19M14 16.35C14.96 16 16.12 15.83 17.5 15.83C18.54 15.83 19.38 15.91 20 |
| 25 | +16.07V14.57C19.13 14.41 18.29 14.33 17.5 14.33C16.16 14.33 15 14.5 14 |
| 26 | +14.76V16.35M14 13.69C14.96 13.34 16.12 13.16 17.5 13.16C18.54 13.16 19.38 13.24 |
| 27 | +20 13.4V11.9C19.13 11.74 18.29 11.67 17.5 11.67C16.22 11.67 15.05 11.82 14 |
| 28 | +12.12V13.69M14 11C14.96 10.67 16.12 10.5 17.5 10.5C18.41 10.5 19.26 10.59 20 |
| 29 | +10.78V9.23C19.13 9.08 18.29 9 17.5 9C16.18 9 15 9.15 14 9.46V11Z"/></svg>""" |
| 30 | + |
| 31 | +icon = folium.DivIcon( |
| 32 | + icon_anchor=(15, 15), |
| 33 | + html=f"<div>{svg}</div>", |
| 34 | +) |
| 35 | + |
| 36 | + |
| 37 | +folium.Marker( |
| 38 | + location=(38.886970844230866, -77.00471380332), |
| 39 | + popup="Library of Congress: James Madison Building", |
| 40 | + icon=icon, |
| 41 | +).add_to(m) |
| 42 | + |
| 43 | +folium.Marker(location=loc_coordinates, popup="Library of Congress", icon=icon).add_to( |
| 44 | + m |
| 45 | +) |
0 commit comments