-
Notifications
You must be signed in to change notification settings - Fork 0
/
deck-gl-layer-behavior.html
215 lines (207 loc) · 7.4 KB
/
deck-gl-layer-behavior.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<link rel="import" href="../polymer/polymer.html">
<script>
(function(DeckGLPolymer) {
/*
* The `DeckGLPolymer.BaseLayer` behavior is the wrapper for the Layer class in deck.gl.
* It provides a number of base properties which are availabe in all layers.
* @polymerBehavior
*/
DeckGLPolymer.BaseLayer = {
properties: {
fp64: {
type: Boolean,
value: false
},
/*
* The id must be unique among all your layers. The layer's id defaults
* to the Layer class name. If you have more than one instance of the
* same Layer subclass you must supply unique id strings.
*
* Note that for sublayers, the actual layer id is going to be the
* supplied layer id appended to the parent layer's (i.e. the composite
* layer's) id, which helps avoid id collisions in this case.
*/
layerId: {
type: String,
value: null
},
/*
* Whether layer responds to mouse events.
*/
pickable: {
type: Boolean,
value: false
},
/*
* Whether layer is drawn.
*
* For performance reasons it is often better to control layer
* visibility with the hide property rather than through conditional
* rendering.
*/
hide: {
type: Boolean,
value: false
},
/*
* The opacity of the layer. deck.gl automatically applies gamma to the
* opacity in an attempt to make opacity changes appear linear (i.e. the
* opacity is visually proportional to the value of the prop.)
*
* Note: While it is a recommended convention that all deck.gl layers
* should support the opacity prop, it is up to each layer's fragment
* shader to implement support for opacity.
*/
opacity: {
type: Number,
value: 1.0
},
/*
* The data prop should contain an iterable JavaScript container,
* please see JavaScript [Symbol.iterator].
*/
data: {
type: Array,
value: null
},
/*
* Whether data prop is an Object (instead of an Array).
*
* deck.gl will automatically supply a `dataIterator` if set to true.
*/
dataIsObject: {
type: Boolean,
value: false
},
/*
* Normally the iterator for data is extracted by looking at the
* [Symbol.iterator] field of the supplied container. Sometimes
* [Symbol.iterator] is not defined, or doesn't provide the desired
* iteration order, so deck.gl allows you to supply your own iterator.
*
* Note: deck.gl even supplies an object iterator
* (makeObjectValueIterator) making it possible to use objects directly
* as data props in deck.gl without first converting them to arrays.
*/
dataIterator: {
type: Object,
value: null
},
/*
* Specifies how layer positions and offsets should be interpreted.
*
* The default is to interpret positions as latitude and longitude,
* however it is also possible to interpret positions as meter offsets
* from the projectionCenter prop.
*
* See the article on [Coordinate Systems](https://uber.github.io/deck.gl/#/documentation/advanced-topics/coordinate-systems) for details.
*
* *Note:
* Normally only used when the application wants to work with
* coordinates that are not Web Mercator projected longitudes/latitudes.*
*/
projectionMode: {
type: Number,
value: null
},
/*
* Required when the projectionMode is in meter offsets.
*
* Specifies a longitude and a latitude from which meter offsets are calculated.
*
* See the article on [Coordinate Systems](https://uber.github.io/deck.gl/#/documentation/advanced-topics/coordinate-systems) for details.
*
* *Note:
* Normally only used when the application wants to work with
* coordinates that are not Web Mercator projected longitudes/latitudes.*
*/
projectionCenter: {
type: Array,
value: null
},
/*
* An optional 4x4 matrix that is premultiplied into the affine
* projection matrices used by shader project GLSL function and the
* Viewport's project and unproject JavaScript function.
*
* Allows local coordinate system transformations to be applied to a
* layer, which is useful when composing data from multiple sources that
* use different coordinate systems.
*
* Note that the matrix projection is applied after the non-linear
* mercator projection calculations are resolved, so be careful when
* using view matrices with lng/lat encoded coordinates.
*
* *Note:
* Normally only used when the application wants to work with
* coordinates that are not Web Mercator projected longitudes/latitudes.*
*/
viewMatrix: {
type: Array,
value: null
},
/*
* This prop causes the data prop to be compared using a custom
* comparison function. The comparison function is called with the old
* data and the new data objects, and is expected to return true if they
* compare equally.
*
* Used to override the default shallow comparison of the data object.
*
* As an illustration, the app could set this to e.g. 'lodash.isequal',
* enabling deep comparison of the data structure. This particular
* examples would obviously have considerable performance impact and
* should only be used as a temporary solution for small data sets until
* the application can be refactored to avoid the need.
*/
dataComparator: {
type: Object,
value: null
},
/*
* deck.gl is often able to autodetect the number of objects in your
* data prop, however in special situations it can be useful to control
* this directly.
*/
numInstances: {
type: Number,
value: null
},
_props: Object
},
observers: [
'_updateProps(layerId, pickable, hide, opacity, data, dataIsObject, dataIterator, projectionMode, projectionCenter, viewMatrix, dataComparator, numInstances)'
],
_updateProps: function() {
this._props = this._getBaseProps();
},
_cleanObject: function(map) {
if (!map) return {};
for (var key in map) {
if (map[key] === null || map[key] === undefined) delete map[key];
}
return map;
},
_getBaseProps: function() {
if (!this.data) return;
this.dataIterator = this.dataIsObject
? DeckGL.makeObjectValueIterator(this.data)
: null;
var props = {
visible: !this.hide,
fp64: this.fp64,
opacity: this.opacity,
data: this.data,
layerId: this.layerId,
pickable: this.pickable,
dataIterator: this.dataIterator,
projectionMode: this.projectionMode,
projectionCenter: this.projectionCenter,
viewMatrix: this.viewMatrix,
numInstances: this.numInstances
};
return props;
}
};
})((window.DeckGLPolymer = window.DeckGLPolymer || {}));
</script>