-
Notifications
You must be signed in to change notification settings - Fork 0
/
scatterplot-layer.html
86 lines (77 loc) · 2.37 KB
/
scatterplot-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
86
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="./deck-gl-layer-behavior.html">
<dom-module id="scatterplot-layer">
<script>
/*
* The `scatterplot-layer` wraps around the [Scatterplot Layer](https://uber.github.io/deck.gl/#/layers/core-layers/scatterplot-layer) in deck.gl.
*
* It takes in paired latitude and longitude coordinated points and renders them as circles with a certain radius.
*
* @demo demo/index.html
*/
Polymer({
is: 'scatterplot-layer',
behaviors: [
DeckGLPolymer.BaseLayer
],
properties: {
/*
* Width of stroke if drawing outline.
*/
strokeWidth: {
type: Number,
value: 1
},
/*
* Global radius across all markers.
*/
radius: {
type: Number,
value: 30
},
/*
* Only draw outline of dot.
*/
drawOutline: {
type: Boolean,
value: false
},
/*
* A map of accessor functions to retrieve specific data from the
* dataset. The following accessors are available for ScatterplotLayer:
* - getPosition (default: object => object.position)
* - getRadius (default: object => object.radius)
* - getColor (default: object => object.color)
*/
accessorFunctions: {
type: Object,
value: null
}
},
observers: [
'_updateProps(strokeWidth, radius, drawOutline, accessorFunctions)',
'_updateLayer(_props)'
],
get layer() {
return new DeckGL.ScatterplotLayer(this._cleanObject(this._props));
},
_updateProps: function() {
if (!this.data) return;
var props = this._getBaseProps();
props.strokeWidth = this.strokeWidth;
props.radius = this.radius;
props.drawOutline = this.drawOutline;
if (this.accessorFunctions) {
props.getPosition = this.accessorFunctions.getPosition;
props.getRadius = this.accessorFunctions.getRadius;
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>