-
Notifications
You must be signed in to change notification settings - Fork 0
/
polygon-layer.html
79 lines (73 loc) · 2.32 KB
/
polygon-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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="./deck-gl-layer-behavior.html">
<dom-module id="polygon-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: 'polygon-layer',
behaviors: [DeckGLPolymer.BaseLayer],
properties: {
lightSettings: {
type: Object,
value: null
},
extruded: {
type: Boolean,
value: false
},
wireframe: {
type: Boolean,
value: false
},
/*
* 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(extruded, wireframe, accessorFunctions)',
'_updateLayer(_props)'
],
get layer() {
if (!this.data) return;
return new DeckGL.PolygonLayer(this._cleanObject(this._props));
},
_updateProps: function() {
if (!this.data) return;
var props = this._getBaseProps();
props.extruded = this.extruded;
props.wireframe = this.wireframe;
if (this.lightSettings) props.lightSettings = this.lightSettings;
if (this.accessorFunctions) {
props.getPolygon = this.accessorFunctions.getPolygon;
props.getElevation = this.accessorFunctions.getElevation;
props.getFillColor = this.accessorFunctions.getFillColor;
}
this._props = props;
},
_updateLayer: function(_props) {
if (!_props) return;
this.fire('layer-updated', this.layer, { node: this.parentNode });
}
});
</script>
</dom-module>