-
Notifications
You must be signed in to change notification settings - Fork 0
/
extruded-choropleth-layer.html
85 lines (77 loc) · 2.46 KB
/
extruded-choropleth-layer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="./deck-gl-layer-behavior.html">
<dom-module id="extruded-choropleth-layer">
<script>
/*
* The `choropleth-layer` wraps around the [ChoroplethLayer](https://uber.github.io/deck.gl/#/layers/core-layers/choropleth-layer) in deck.gl.
*
* The Choropleth Layer takes in GeoJson formatted data and renders it as interactive choropleths.
*
* By supplying a GeoJson FeatureCollection you can add multiple polygons.
* Each Feature has an optional "properties" object. The layer will look for
* an optional property color, which is expected to be a 4 element array of
* values between 0 and 255, representing the rgba values for the color of
* that Feature.
*
* If not provided, the default rgba will be [0, 0, 255, 255].
*
* @demo demo/choropleth-layer.html
*/
Polymer({
is: 'extruded-choropleth-layer',
behaviors: [
DeckGLPolymer.BaseLayer
],
properties: {
/*
* color of the extruded geometry
*/
color: {
type: Array,
value: function() {
return [74, 80, 87];
}
},
/*
* Elevation scale
*/
elevation: {
type: Number,
value: 1
},
/*
* A map of accessor functions to retrieve specific data from the
* dataset. The following accessors are available for ChoroplethLayer:
* - getColor (default: feature => feature.properties.color)
*/
accessorFunctions: {
type: Object,
value: null
}
},
observers: [
'_updateProps(color, elevation, accessorFunctions)',
'_updateLayer(_props)'
],
get layer() {
if (!this.data) return;
return new DeckGL.ExtrudedChoroplethLayer64(this._cleanObject(this._props));
},
_updateProps: function() {
if (!this.data) return;
var self = this;
var props = this._getBaseProps();
props.color = this.color || [74, 80, 87];
props.elevation = this.elevation || 1;
if (this.accessorFunctions) {
props.getColor = this.accessorFunctions.getColor;
}
this._props = props;
},
_updateLayer: function(_props) {
if (!_props) return;
this.fire('layer-updated', this.layer, {node: this.parentNode});
}
});
</script>
</dom-module>