mapbox / mapboxgl-jupyter

Use Mapbox GL JS to visualize data in a Python Jupyter notebook
MIT License
661 stars 136 forks source link

Map control scale bar #151

Closed akacarlyann closed 5 years ago

akacarlyann commented 5 years ago

Optionally add a map control scale bar to any MapViz with custom position and styling. Closes #143.

Usage example:

import os
from mapboxgl.viz import *

# Create the viz from the dataframe
viz = CircleViz('../data/healthcare_points.geojson',
                access_token=os.getenv('MAPBOX_ACCESS_TOKEN'), 
                center=(-95, 40),
                zoom=2.5,
                scale=True,
                scale_unit_system='imperial',
                scale_position='top-left',
                scale_border_color='#6e6e6e', 
                scale_background_color='#eee',
                scale_text_color='#131516')

# Show the viz
viz.show()
scale bar
akacarlyann commented 5 years ago

Sure thing! I had added one example to https://github.com/akacarlyann/mapboxgl-jupyter/blob/map-scale/examples/notebooks/scale-annotation.ipynb before opening the PR. @ryanbaumann Which notebook should I integrate this into?

ryanbaumann commented 5 years ago

I'd recommend adding to https://github.com/mapbox/mapboxgl-jupyter/blob/master/examples/notebooks/point-viz-types-example.ipynb

akacarlyann commented 5 years ago

@ryanbaumann sounds good. Added in 57f9014.

ryanbaumann commented 5 years ago

Looks good - ready to merge if you are @akacarlyann

akacarlyann commented 5 years ago

@ryanbaumann It's ready!