-
Notifications
You must be signed in to change notification settings - Fork 0
/
line-layer.html
70 lines (61 loc) · 2.04 KB
/
line-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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="./deck-gl-layer-behavior.html">
<dom-module id="line-layer">
<script>
/*
* The `line-layer` wraps around the [Line Layer](https://uber.github.io/deck.gl/#/layers/core-layers/line-layer) in deck.gl.
*
* The Line Layer takes in paired latitude and longitude coordinated points and render them as arcs that links the starting and ending points.
*
* @demo demo/line-layer.html
*/
Polymer({
is: 'line-layer',
behaviors: [
DeckGLPolymer.BaseLayer
],
properties: {
/*
* The stroke width used to draw each line.
*/
strokeWidth: {
type: Number,
value: 1
},
/*
* A map of accessor functions to retrieve specific data from the
* dataset. The following accessors are available for LineLayer:
* - getSourcePosition (default: object => object.sourcePosition)
* - getTargetPosition (default: object => object.targetPosition)
* - getColor (default: object => object.color)
*/
accessorFunctions: {
type: Object,
value: null
}
},
observers: [
'_updateProps(strokeWidth, accessorFunctions)',
'_updateLayer(_props)'
],
get layer() {
return new DeckGL.LineLayer(this._cleanObject(this._props));
},
_updateProps: function() {
if (!this.data) return;
var props = this._getBaseProps();
props.strokeWidth = this.strokeWidth;
if (this.accessorFunctions) {
props.getSourcePosition = this.accessorFunctions.getSourcePosition;
props.getTargetPosition = this.accessorFunctions.getTargetPosition;
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>