forked from mapbox/mapboxgl-jupyter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support vector tile source for additional viz types (mapbox#120)
* Update text-size to use expression based on viz.label_size property * Add new label properties to choropleth viz templates * Move label properties to base class (leverage inheritance to reduce repeated arguments) * Extract vector_color_map and numeric map (for height or line_width) to a VectorMixin class; fixes linestring bug with interpolation of color for certain color lookups with match-type * Extend CircleViz with VectorMixin (start GraduatedCircleViz, HeatmapViz, ClusteredCircleViz) * Extend vector data loading to base map and CircleMap -- datadriven styling for radius needs work * Refine color mapping in VectorMixin and update templates, viz.py * Update CircleViz template files with Jinja inheritance, establish {% block circle %} tag * Update Vector layer example for CircleViz; add geojson_file_to_dict utility and logic to viz.py to facilitate loading data from JSON object, list of Python dicts, GeoJSON filename * Refine function for parsing GeoJSON and JSON input (esp for vector visualizations) and add SourceDataError * Add support for GraduatedCircleViz template to use vector source data layer * Add support for HeatmapViz to use vector data source * Add and refine tests; update utility name for geojson_to_dict etc. * Change FileNotFoundError to IOError for Python2.7 support * Enable data from vector layers to be used for data-driven style (without using data-join technique) * Update docs for VectorMixin class, vector properties and label properties inherited from MapViz parent class * Update geojson_to_dict to geojson_to_dict_list and add docs; organize MapBox.create_html()
- Loading branch information
1 parent
5fa857b
commit ad77d79
Showing
23 changed files
with
5,699 additions
and
3,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
class TokenError(ValueError): | ||
pass | ||
|
||
|
||
class ValueError(ValueError): | ||
pass | ||
|
||
|
||
class SourceDataError(ValueError): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//https://www.mapbox.com/help/custom-markers-gl-js/ | ||
|
||
{% extends "base.html" %} | ||
|
||
{% block legend %}{% endblock legend %} | ||
|
||
{% block map %} | ||
|
||
map.on('style.load', function() { | ||
|
||
// Add data source | ||
map.addSource("data", { | ||
"type": "geojson", | ||
"data": {{ geojson_data }}, | ||
"buffer": 1, | ||
"maxzoom": 14 | ||
}); | ||
|
||
// Add symbol layer | ||
map.addLayer({ | ||
"id": "symbol", | ||
"source": "data", | ||
"type": "symbol", | ||
"maxzoom": {{ maxzoom }}, | ||
"minzoom": {{ minzoom }}, | ||
|
||
"layout": { | ||
{% if labelProperty %} | ||
"text-field": "{{ labelProperty }}", | ||
{% endif %} | ||
"text-size" : generateInterpolateExpression('zoom', [[0, {{ labelSize }}],[22, 3* {{ labelSize }}]] ), | ||
"text-offset": [0,-1] | ||
}, | ||
"paint": { | ||
"text-halo-color": "{{ labelHaloColor }}", | ||
"text-halo-width": generatePropertyExpression('interpolate', 'zoom', [[0,{{ labelHaloWidth }}], [18,5* {{ labelHaloWidth }}]]), | ||
"text-color": "{{ labelColor }}" | ||
} | ||
}, "{{ belowLayer }}" ); | ||
|
||
// Add label layer | ||
map.addLayer({ | ||
"id": "symbol-label", | ||
"source": "data", | ||
"type": "symbol", | ||
"maxzoom": {{ maxzoom }}, | ||
"minzoom": {{ minzoom }}, | ||
"layout": { | ||
{% if labelProperty %} | ||
"text-field": "{{ labelProperty }}", | ||
{% endif %} | ||
"text-size" : generateInterpolateExpression('zoom', [[0, {{ labelSize }}],[22, 3* {{ labelSize }}]] ), | ||
"text-offset": [0,-1] | ||
}, | ||
"paint": { | ||
"text-halo-color": "{{ labelHaloColor }}", | ||
"text-halo-width": generatePropertyExpression('interpolate', 'zoom', [[0,{{ labelHaloWidth }}], [18,5* {{ labelHaloWidth }}]]), | ||
"text-color": "{{ labelColor }}" | ||
} | ||
}, "{{ belowLayer }}" ); | ||
|
||
}); | ||
|
||
{% endblock map %} |
Oops, something went wrong.