Mapbox utilization

Stuff I am working on
Post Reply
Daniel Wee
Site Admin
Posts: 2449
Joined: Wed 25 Feb 25 2009 8:00 pm

Mapbox utilization

Post by Daniel Wee »

For offline calculation of tiles required, use:-

https://www.mapbox.com/help/offline-estimator/

Bounding box of:
SW 1.21766 103.60073
NE 1.47212 104.03532

Min zoom: 10
Max zoom: 16

Tiles required: 5300
Daniel Wee
Site Admin
Posts: 2449
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Mapbox utilization

Post by Daniel Wee »

Minimal code using offline plotly here. Outputs a map with a marker to a named html file which can then be opened up in a browser.

For more info on offline mode, see:-

https://www.reddit.com/r/IPython/commen ... line_mode/

Code: Select all

import  plotly.offline  as py
from plotly.graph_objs import *

mapbox_access_token = 'PLACE MAPBOX TOKEN HERE'

data = Data([
    Scattermapbox(
        lat=['1.30767442232997'],
        lon=['103.796271571462'],
        mode='markers',
        marker=Marker(
            size=14
        ),
        text=['272005'],
    )
])

layout = Layout(
    autosize=True,
    hovermode='closest',
    mapbox=dict(
        accesstoken=mapbox_access_token,
        bearing=0,
        center=dict(
            lat=1.347865,
            lon=103.81622
        ),
        pitch=0,
        zoom=10
    ),
)

fig = dict(data=data, layout=layout)
py.plot(fig, filename='Singapore-Mapbox.html')
Daniel Wee
Site Admin
Posts: 2449
Joined: Wed 25 Feb 25 2009 8:00 pm

Re: Mapbox utilization

Post by Daniel Wee »

For multiple markers in an array, see:-

https://plot.ly/python/scattermapbox/#new-to-plotly
Post Reply