Skip to content

Commit 01db110

Browse files
author
Natalia Kowalczyk
committed
wip: global-state in demo
1 parent 2442709 commit 01db110

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

demo/map-style.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
},
1111
"sprite": "https://tiles.openfreemap.org/sprites/ofm_f384/ofm",
1212
"glyphs": "https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf",
13+
"state": {
14+
"lineColor": { "default": "#A21BAB" }
15+
},
1316
"layers": [
1417
{
1518
"id": "background",
@@ -1100,7 +1103,7 @@
11001103
},
11011104
"metadata": {},
11021105
"paint": {
1103-
"line-color": "#a21bab",
1106+
"line-color": ["global-state", "lineColor"],
11041107
"line-opacity": 0.8,
11051108
"line-width": 4
11061109
},
@@ -1160,7 +1163,7 @@
11601163
},
11611164
"metadata": {},
11621165
"paint": {
1163-
"line-color": "#a21bab",
1166+
"line-color": ["global-state", "lineColor"],
11641167
"line-opacity": 0.8,
11651168
"line-width": 4
11661169
},
@@ -1210,7 +1213,7 @@
12101213
},
12111214
"metadata": {},
12121215
"paint": {
1213-
"line-color": "#a21bab",
1216+
"line-color": ["global-state", "lineColor"],
12141217
"line-opacity": 0.8,
12151218
"line-width": 4
12161219
},
@@ -1253,7 +1256,7 @@
12531256
},
12541257
"metadata": {},
12551258
"paint": {
1256-
"line-color": "#a21bab",
1259+
"line-color": ["global-state", "lineColor"],
12571260
"line-opacity": 0.8,
12581261
"line-width": 4
12591262
},
@@ -1336,7 +1339,7 @@
13361339
},
13371340
"metadata": {},
13381341
"paint": {
1339-
"line-color": "#a21bab",
1342+
"line-color": ["coalesce", ["get", "color"], ["global-state", "lineColor"]],
13401343
"line-dasharray": [2, 3],
13411344
"line-width": 4
13421345
},
@@ -1349,7 +1352,7 @@
13491352
"layout": {},
13501353
"metadata": {},
13511354
"paint": {
1352-
"fill-color": "#A21BAB",
1355+
"fill-color": ["global-state", "lineColor"],
13531356
"fill-opacity": 0.5,
13541357
"fill-outline-color": "#0074D9"
13551358
},

demo/samples/china.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@ function sampleChina(_, map, source) {
4949
setTimeout(function () {
5050
map.move({ zoom: 17, center: center }, false);
5151
}, 0);
52+
setTimeout(function () {
53+
map._m.setGlobalStateProperty('lineColor', '#ff0000');
54+
}, 5000);
5255
}

0 commit comments

Comments
 (0)