show waypointes in map in python

To show waypoints in a map using Python, you can use the folium library. folium is a powerful library that allows you to create various types of maps, including interactive maps.

Here's a code snippet that shows how to create a map with waypoints using folium:

main.py
import folium

# Create a map object
m = folium.Map(location=[40.7128, -74.0060], zoom_start=12)

# Define the waypoints
waypoints = [[40.7128, -74.0060], [40.7128, -73.9960], 
            [40.7228, -74.0060], [40.7228, -73.9960]]

# Iterate through the waypoints and add them to the map
for point in waypoints:
    folium.Marker(location=point).add_to(m)

# Display the map
m
377 chars
16 lines

In this code snippet, we first create a folium map object by specifying the location and zoom_start parameters. We then define the waypoints as a list of latitude/longitude pairs. We then iterate through the waypoints using a for loop and add a marker for each waypoint to the map using the folium.Marker() method. Finally, we display the map using the m object.

gistlibby LogSnag