python-visualization / folium

Python Data. Leaflet.js Maps.

Home Page:https://python-visualization.github.io/folium/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

draw ployline along with street view

sandiemann opened this issue · comments

Describe the bug
I want to draw the polyline that connects between two coordinate points but it always draws as a straight line.
To Reproduce

my_map = folium.Map(location=df['Coordinates'].iloc[0][0], zoom_start=12)

    for index, row in df.iterrows():
        routes = row['Named_Routes']
        coords = row['Coordinates']

        if start_route_name in routes and end_route_name in routes:

            folium.Marker(location=coords[0], popup=f"Start: {routes[0]}", icon=folium.Icon(color='green')).add_to(
                my_map)
            folium.Marker(location=coords[-1], popup=f"End: {routes[-1]}", icon=folium.Icon(color='red')).add_to(my_map)


            for i in range(1, len(coords) - 1):
                folium.Marker(location=coords[i],
                              icon=folium.Icon(color='blue', icon_color='white', prefix='fa', icon='bus'),
                              popup=f"Route: {routes[i]}", tooltip=f"Route: {routes[i]}").add_to(my_map)

Expected behavior
I prefer the line go over the nearest street view to connect coordinates, possibly osmx impl. because the route looks like the way over the park.
Could you suggest how to overcome this issue?

Screenshot 2024-01-27 at 20 30 04

found a workaround on OSM. closing this.