Skip to content

Commit

Permalink
Merge 1468499 into 7b04bf5
Browse files Browse the repository at this point in the history
  • Loading branch information
akacarlyann committed Aug 26, 2018
2 parents 7b04bf5 + 1468499 commit 663ebf8
Show file tree
Hide file tree
Showing 23 changed files with 5,699 additions and 3,630 deletions.
10 changes: 10 additions & 0 deletions docs/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ data = df_to_geojson(
)
```

## geojson_to_dict_list
Convert data passed as GeoJSON object, filename, URL to a Python list of dictionaries representing the join data from each feature.

### Params
**geojson_to_dict_list**(_data_)

Parameter | Description
--|--
data | GeoJSON join-data for use with vector tiles

## scale_between
Scale a minimum and maximum value to an equal interval domain list, with `numStops` values in in the list.

Expand Down
250 changes: 123 additions & 127 deletions docs/viz.md

Large diffs are not rendered by default.

6,346 changes: 3,173 additions & 3,173 deletions examples/data/healthcare_points.geojson

Large diffs are not rendered by default.

1,457 changes: 1,457 additions & 0 deletions examples/notebooks/circle-vector.ipynb

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions mapboxgl/errors.py
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
8 changes: 4 additions & 4 deletions mapboxgl/templates/choropleth.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@
{% if labelProperty %}
"text-field": "{{ labelProperty }}",
{% endif %}
"text-size" : generateInterpolateExpression('zoom', [[0,8],[22,16]] ),
"text-size" : generateInterpolateExpression('zoom', [[0, {{ labelSize }}],[22, 3* {{ labelSize }}]] ),
"text-offset": [0,-1]
},
"paint": {
"text-halo-color": "white",
"text-halo-width": 1
"text-halo-color": "{{ labelHaloColor }}",
"text-halo-width": generatePropertyExpression('interpolate', 'zoom', [[0,{{ labelHaloWidth }}], [18,5* {{ labelHaloWidth }}]]),
"text-color": "{{ labelColor }}"
}
}, "{{ belowLayer }}" );

Expand All @@ -103,7 +104,6 @@

{% endif %}


{% endblock choropleth %}

// Create a popup
Expand Down
8 changes: 8 additions & 0 deletions mapboxgl/templates/circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

map.on('style.load', function() {

{% block circle %}

map.addSource("data", {
"type": "geojson",
"data": {{ geojson_data }},
Expand Down Expand Up @@ -68,11 +70,15 @@
}
}, "label");

{% endblock circle %}

// Create a popup
var popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false
});

{% block circle_popup %}

// Show the popup on mouseover
map.on('mousemove', 'circle', function(e) {
Expand All @@ -92,6 +98,8 @@
.addTo(map);
});

{% endblock circle_popup %}

map.on('mouseleave', 'circle', function() {
map.getCanvas().style.cursor = '';
popup.remove();
Expand Down
9 changes: 8 additions & 1 deletion mapboxgl/templates/clustered_circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

map.on('style.load', function() {

{% block clustered_circle %}

map.addSource("data", {
"type": "geojson",
"data": {{ geojson_data }}, //data from dataframe output to geojson
Expand Down Expand Up @@ -80,12 +82,16 @@
}
}, "circle-cluster");

{% endblock clustered_circle %}

// Create a popup
var popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false
});

{% block clustered_circle_popup %}

// Show the popup on mouseover
map.on('mousemove', 'circle-unclustered', function(e) {
map.getCanvas().style.cursor = 'pointer';
Expand Down Expand Up @@ -119,6 +125,8 @@
.addTo(map);
});

{% endblock clustered_circle_popup %}

map.on('mouseleave', 'circle-unclustered', function() {
map.getCanvas().style.cursor = '';
popup.remove();
Expand All @@ -129,7 +137,6 @@
popup.remove();
});


map.on('click', 'circle-unclustered', function(e) {
map.easeTo({
center: e.features[0].geometry.coordinates,
Expand Down
8 changes: 8 additions & 0 deletions mapboxgl/templates/graduated_circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

map.on('style.load', function() {

{% block graduated_circle %}

map.addSource("data", {
"type": "geojson",
"data": {{ geojson_data }}, //data from dataframe output to geojson
Expand Down Expand Up @@ -72,11 +74,15 @@
}
}, "label");

{% endblock graduated_circle %}

// Create a popup
var popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false
});

{% block graduated_circle_popup %}

// Show the popup on mouseover
map.on('mousemove', 'circle', function(e) {
Expand All @@ -96,6 +102,8 @@
.addTo(map);
});

{% endblock graduated_circle_popup %}

map.on('mouseleave', 'circle', function() {
map.getCanvas().style.cursor = '';
popup.remove();
Expand Down
6 changes: 5 additions & 1 deletion mapboxgl/templates/heatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

map.on('style.load', function() {

{% block heatmap %}

map.addSource("data", {
"type": "geojson",
"data": {{ geojson_data }}, //data from dataframe output to geojson
Expand All @@ -14,7 +16,7 @@
});

map.addLayer({
"id": "circle",
"id": "heatmap",
"source": "data",
"type": "heatmap",
"maxzoom": {{ maxzoom }},
Expand All @@ -35,6 +37,8 @@
"heatmap-opacity" : {{ opacity }}
}
}, "{{belowLayer}}" );

{% endblock heatmap %}

});

Expand Down
2 changes: 1 addition & 1 deletion mapboxgl/templates/linestring.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{% if labelProperty %}
"text-field": "{{ labelProperty }}",
{% endif %}
"text-size" : generateInterpolateExpression('zoom', [[0,8],[22,16]] ),
"text-size" : generateInterpolateExpression('zoom', [[0, {{ labelSize }}],[22, 3* {{ labelSize }}]] ),
"text-offset": [0,-1]
},
"paint": {
Expand Down
64 changes: 64 additions & 0 deletions mapboxgl/templates/symbol.html
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 %}
Loading

0 comments on commit 663ebf8

Please sign in to comment.