✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

How to plot lines between locations on a map at a city level=

Hi all,

I am trying to plot markers and lines between markers on a map. The markers are distributed across a city so it would be nice to have detailed location information on the street names, city areas, etc. The following example uses mapbox to provide the map titles but it does not allow to draw lines between markers (it allows only to draw the markers): https://plot.ly/python/scattermapbox/

On the other hand, the following example allows to draw markers and lines between markers but the maximum map “resolution” is at country level (i.e., it is not possible to identify individual streets): https://plot.ly/python/lines-on-maps/

Is there any option to draw lines and markers on a map with street level resolution for the map tiles?


@mimapper You can draw lines on a map plotted by mapbox, too.
The lon and lat along the lines should be defined within a dict having the structure of a geojson type file https://en.wikipedia.org/wiki/GeoJSON.

Pass the dict to mapbox via layers:

layers=[dict(sourcetype = 'geojson',
         source =the_geojson_type_dict,
         type = 'line',
layout = dict(
title='Lines in mapbox, via geojson data',


See also in this example https://www.mapbox.com/mapbox-gl-js/example/geojson-line/
how the geojson type dict can be defined inside the layer definition.

1 Like

@empet thank you very much for the detailed reply. The answer was really useful to solve the problem.

If someone else also wants to add multiple geometries to a geojson please check the following link:

1 Like

@empet How to make India map based on Indian state???

Hi @apache

Could you be more precise, please? Do you intend to plot the boundaries for India states
India districts https://github.com/geohacker/india/blob/master/district/india_district.geojson
or the choropleth of one of these administrative divisions?

@empet I now have GMV data for each state in India, and give each state a different color based on the GMV。
IT’s my demand~