-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfill-extrusion-layer-behavior.html
116 lines (110 loc) · 3.98 KB
/
fill-extrusion-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
<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="./layer-behavior.html">
<script>
(function(MapboxGLPolymer) {
/*
* @polymerBehavior
*/
MapboxGLPolymer.FillExtrusionLayerBehaviorImplementation = {
properties: {
/*
* Rendering type of this layer.
* (fill, line, symbol, circle, fill-extrusion, raster, background)
*/
renderingType: {
type: String,
value: 'fill-extrusion'
},
/*
* The opacity of the entire fill extrusion layer. This is rendered on
* a per-layer, not per-feature, basis, and data-driven styling is not
* available.
*/
fillExtrusionOpacity: {
type: Number,
value: 1
},
/*
* The base color of the extruded fill. The extrusion's surfaces will be
* shaded differently based on this color in combination with the root
* light settings. If this color is specified as rgba with an alpha
* component, the alpha component will be ignored; use
* fill-extrusion-opacity to set layer opacity.
*/
fillExtrusionColor: {
type: String,
value: '#000000'
},
/*
* The geometry's offset. Values are [x, y] where negatives indicate
* left and up (on the flat plane), respectively.
*/
fillExtrusionTranslate: {
type: Array,
value: function() {
return [0, 0];
}
},
/*
* Controls the translation reference point (map or viewport).
*/
fillExtrusionTranslateAnchor: {
type: String
},
/*
* Name of image in sprite to use for drawing images on extruded fills.
* For seamless patterns, image width and height must be a factor of
* two (2, 4, 8, ..., 512).
*/
fillExtrusionPattern: {
type: String
},
/*
* The height (in meters) with which to extrude this layer.
*/
fillExtrusionHeight: {
type: Number,
value: 0
},
/*
* The height with which to extrude the base of this layer.
* Must be less than or equal to fill-extrusion-height
*/
fillExtrusionBase: {
type: Number,
value: 0
},
_paint: Object
},
observers: [
'_generatePaintProp(fillExtrusionOpacity, fillExtrusionColor, fillExtrusionTranslate, fillExtrusionHeight, fillExtrusionBase)',
'_updatePaintProp("fill-extrusion-translate-anchor", fillExtrusionTranslateAnchor, _paint)',
'_updatePaintProp("fill-extrusion-pattern", fillExtrusionPattern, _paint)'
],
_generatePaintProp: function(fillExtrusionOpacity, fillExtrusionColor, fillExtrusionTranslate, fillExtrusionHeight, fillExtrusionBase) {
var _paint = Object.create(null);
this._updatePaintProp('fill-extrusion-opacity', fillExtrusionOpacity, _paint);
this._updatePaintProp('fill-extrusion-color', fillExtrusionColor, _paint);
this._updatePaintProp('fill-extrusion-translate', fillExtrusionTranslate, _paint);
this._updatePaintProp('fill-extrusion-height', fillExtrusionHeight, _paint);
this._updatePaintProp('fill-extrusion-base', fillExtrusionBase, _paint);
this._paint = _paint;
},
_updatePaintProp: function(key, value, _paint) {
if (!_paint || !value) return;
if (_paint[key] === value) return;
_paint[key] = value;
// layer already added
if (this._added) {
this.map.setPaintProperty(this.layerId, key, value);
} else {
this.notifyPath('_paint');
}
}
};
/*
* @polymerBehavior
*/
MapboxGLPolymer.FillExtrusionLayerBehavior = [MapboxGLPolymer.LayerBehavior, MapboxGLPolymer.FillExtrusionLayerBehaviorImplementation]
})(window.MapboxGLPolymer = window.MapboxGLPolymer || {});
</script>