Last active
February 27, 2019 20:46
-
-
Save deparkes/eb064bf6fdebf5a06441cd3776d74466 to your computer and use it in GitHub Desktop.
Example of combining lines and markers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import folium | |
points_a = [[1,50], [1.2,50.3], [1.23, 50.7]] | |
points_z = [[1,51], [1.2,51.3], [1.23, 51.7]] | |
# Load map centred on average coordinates | |
ave_lat = sum(p[0] for p in points_a)/len(points_a) | |
ave_lon = sum(p[1] for p in points_a)/len(points_a) | |
my_map = folium.Map(location=[ave_lat, ave_lon], zoom_start=9) | |
#add a markers 'a' | |
for each in points_a: | |
my_map.add_child(folium.CircleMarker(location=each, | |
fill='true', | |
radius = 6, | |
popup= 'Hi', | |
fill_color='blue', | |
color = 'clear', | |
fill_opacity=1)) | |
# add markers 'z' | |
for each in points_z: | |
my_map.add_child(folium.CircleMarker(location=each, | |
fill='true', | |
radius = 6, | |
popup= 'Bye', | |
fill_color='yellow', | |
color = 'clear', | |
fill_opacity=1)) | |
# add lines | |
folium.PolyLine(points_a, color="green", weight=2.5, opacity=1).add_to(my_map) | |
folium.PolyLine(points_z, color="blue", weight=2.5, opacity=1).add_to(my_map) | |
# Save map | |
my_map.save("./lines_withmarker.html") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment