How to draw lines on map in Databricks

Imports:

import plotly.graph_objects as go

Plot:

fig = go.Figure()

fig.add_trace(go.Scattermapbox(
    mode = "markers+lines",
    lon = [10, 20, 30],
    lat = [10, 15,30],
    marker = {'size': 10}))

fig.add_trace(go.Scattermapbox(
    mode = "markers+lines",
    lon = [-50, -60,40],
    lat = [30, 10, -20],
    marker = {'size': 10}))

fig.update_layout(
    margin ={'l':0,'t':0,'b':0,'r':0},
    mapbox = {
        'center': {'lon': 10, 'lat': 10},
        'style': "carto-positron",
        'center': {'lon': -20, 'lat': -20},
        'zoom': 1})

fig.show()

Displays:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.