maplibre-gl 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/rollup_plugins.js +1 -0
- package/dist/maplibre-gl-dev.js +54589 -0
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +1 -1
- package/dist/maplibre-gl.js +2 -2
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +56 -59
- package/src/css/maplibre-gl.css +15 -15
- package/src/source/tile_cache.test.ts +6 -4
- package/src/source/vector_tile_source.test.ts +13 -2
- package/src/source/vector_tile_source.ts +1 -2
- package/src/style/load_glyph_range.test.ts +0 -2
- package/src/style/style.test.ts +20 -13
- package/src/ui/camera.test.ts +4 -4
- package/src/ui/control/logo_control.test.ts +1 -0
- package/src/ui/handler/scroll_zoom.test.ts +2 -1
- package/src/ui/map.test.ts +16 -10
- package/src/ui/map.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplibre-gl",
|
|
3
3
|
"description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"main": "dist/maplibre-gl.js",
|
|
6
6
|
"style": "dist/maplibre-gl.css",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"types": "dist/maplibre-gl.d.ts",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@mapbox/geojson-rewind": "^0.5.
|
|
15
|
+
"@mapbox/geojson-rewind": "^0.5.1",
|
|
16
16
|
"@mapbox/jsonlint-lines-primitives": "^2.0.2",
|
|
17
17
|
"@mapbox/mapbox-gl-supported": "^2.0.1",
|
|
18
18
|
"@mapbox/point-geometry": "^0.1.0",
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
"@mapbox/vector-tile": "^1.3.1",
|
|
22
22
|
"@mapbox/whoots-js": "^3.1.0",
|
|
23
23
|
"csscolorparser": "~1.0.3",
|
|
24
|
-
"earcut": "^2.2.
|
|
24
|
+
"earcut": "^2.2.3",
|
|
25
25
|
"geojson-vt": "^3.2.1",
|
|
26
|
-
"gl-matrix": "^3.
|
|
26
|
+
"gl-matrix": "^3.4.3",
|
|
27
27
|
"murmurhash-js": "^1.0.0",
|
|
28
28
|
"pbf": "^3.2.1",
|
|
29
|
-
"potpack": "^1.0.
|
|
29
|
+
"potpack": "^1.0.2",
|
|
30
30
|
"quickselect": "^2.0.0",
|
|
31
31
|
"supercluster": "^7.1.4",
|
|
32
32
|
"tinyqueue": "^2.0.3",
|
|
33
|
-
"vt-pbf": "^3.1.
|
|
33
|
+
"vt-pbf": "^3.1.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@babel/core": "^7.16.
|
|
36
|
+
"@babel/core": "^7.16.12",
|
|
37
37
|
"@mapbox/gazetteer": "^5.1.0",
|
|
38
|
-
"@mapbox/mapbox-gl-rtl-text": "^0.2.
|
|
38
|
+
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
|
|
39
39
|
"@mapbox/mvt-fixtures": "^3.6.0",
|
|
40
40
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
41
41
|
"@rollup/plugin-json": "^4.1.0",
|
|
@@ -43,77 +43,74 @@
|
|
|
43
43
|
"@rollup/plugin-replace": "^3.0.1",
|
|
44
44
|
"@rollup/plugin-strip": "^2.1.0",
|
|
45
45
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
46
|
-
"@types/babel__core": "^7.1.
|
|
47
|
-
"@types/babelify": "^7.3.
|
|
48
|
-
"@types/benchmark": "^2.1.
|
|
49
|
-
"@types/browserify": "^12.0.
|
|
46
|
+
"@types/babel__core": "^7.1.18",
|
|
47
|
+
"@types/babelify": "^7.3.7",
|
|
48
|
+
"@types/benchmark": "^2.1.1",
|
|
49
|
+
"@types/browserify": "^12.0.37",
|
|
50
50
|
"@types/cssnano": "^5.0.0",
|
|
51
|
-
"@types/d3": "^
|
|
52
|
-
"@types/diff": "^
|
|
51
|
+
"@types/d3": "^7.1.0",
|
|
52
|
+
"@types/diff": "^5.0.2",
|
|
53
53
|
"@types/earcut": "^2.1.1",
|
|
54
54
|
"@types/ejs": "^3.1.0",
|
|
55
|
-
"@types/eslint": "^8.
|
|
55
|
+
"@types/eslint": "^8.4.1",
|
|
56
56
|
"@types/geojson": "^7946.0.8",
|
|
57
57
|
"@types/gl": "^4.1.0",
|
|
58
|
-
"@types/glob": "^7.
|
|
59
|
-
"@types/jest": "^27.0
|
|
58
|
+
"@types/glob": "^7.2.0",
|
|
59
|
+
"@types/jest": "^27.4.0",
|
|
60
60
|
"@types/jsdom": "^16.2.14",
|
|
61
61
|
"@types/lodash.template": "^4.5.0",
|
|
62
62
|
"@types/mapbox__point-geometry": "^0.1.2",
|
|
63
63
|
"@types/mapbox__vector-tile": "^1.3.0",
|
|
64
|
-
"@types/minimist": "^1.2.
|
|
64
|
+
"@types/minimist": "^1.2.2",
|
|
65
65
|
"@types/murmurhash-js": "^1.0.3",
|
|
66
|
-
"@types/node-notifier": "^8.0.
|
|
67
|
-
"@types/offscreencanvas": "^2019.6.
|
|
66
|
+
"@types/node-notifier": "^8.0.2",
|
|
67
|
+
"@types/offscreencanvas": "^2019.6.4",
|
|
68
68
|
"@types/pbf": "^3.0.2",
|
|
69
|
-
"@types/pixelmatch": "^5.2.
|
|
69
|
+
"@types/pixelmatch": "^5.2.4",
|
|
70
70
|
"@types/pngjs": "^6.0.1",
|
|
71
71
|
"@types/puppeteer": "^5.4.4",
|
|
72
|
-
"@types/react": "^17.0.
|
|
73
|
-
"@types/react-dom": "^17.0.
|
|
74
|
-
"@types/request": "^2.48.
|
|
75
|
-
"@types/rollup-plugin-json": "^3.0.
|
|
72
|
+
"@types/react": "^17.0.38",
|
|
73
|
+
"@types/react-dom": "^17.0.11",
|
|
74
|
+
"@types/request": "^2.48.8",
|
|
75
|
+
"@types/rollup-plugin-json": "^3.0.3",
|
|
76
76
|
"@types/selenium-webdriver": "^4.0.16",
|
|
77
77
|
"@types/shuffle-seed": "^1.1.0",
|
|
78
|
-
"@types/sinon": "^10.0.
|
|
79
|
-
"@types/
|
|
80
|
-
"@types/supercluster": "^5.0.2",
|
|
78
|
+
"@types/sinon": "^10.0.9",
|
|
79
|
+
"@types/supercluster": "^5.0.3",
|
|
81
80
|
"@types/tape": "^4.13.2",
|
|
82
81
|
"@types/window-or-global": "^1.0.4",
|
|
83
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
84
|
-
"@typescript-eslint/parser": "^5.
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
83
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
85
84
|
"address": "^1.1.2",
|
|
86
85
|
"babel-eslint": "^10.0.1",
|
|
87
|
-
"babel-jest": "^27.
|
|
86
|
+
"babel-jest": "^27.4.6",
|
|
88
87
|
"babelify": "^10.0.0",
|
|
89
88
|
"benchmark": "^2.1.4",
|
|
90
89
|
"browserify": "^17.0.0",
|
|
91
90
|
"canvas": "^2.9.0",
|
|
92
|
-
"chokidar": "^3.
|
|
93
|
-
"cssnano": "^5.0.
|
|
94
|
-
"d3": "^
|
|
91
|
+
"chokidar": "^3.5.3",
|
|
92
|
+
"cssnano": "^5.0.16",
|
|
93
|
+
"d3": "^7.3.0",
|
|
95
94
|
"d3-queue": "^3.0.7",
|
|
96
|
-
"diff": "^
|
|
97
|
-
"documentation": "
|
|
98
|
-
"dts-bundle-generator": "^6.
|
|
95
|
+
"diff": "^5.0.0",
|
|
96
|
+
"documentation": "13.0.2",
|
|
97
|
+
"dts-bundle-generator": "^6.4.0",
|
|
99
98
|
"ejs": "^3.1.6",
|
|
100
99
|
"eslint": "^8.7.0",
|
|
101
100
|
"eslint-config-mourner": "^3.0.0",
|
|
102
|
-
"eslint-plugin-html": "^6.
|
|
103
|
-
"eslint-plugin-import": "^2.
|
|
101
|
+
"eslint-plugin-html": "^6.2.0",
|
|
102
|
+
"eslint-plugin-import": "^2.25.4",
|
|
104
103
|
"eslint-plugin-jest": "^26.0.0",
|
|
105
|
-
"eslint-plugin-jsdoc": "^37.0
|
|
106
|
-
"eslint-plugin-react": "^7.
|
|
104
|
+
"eslint-plugin-jsdoc": "^37.7.0",
|
|
105
|
+
"eslint-plugin-react": "^7.28.0",
|
|
107
106
|
"gl": "^5.0.0",
|
|
108
|
-
"glob": "^7.
|
|
109
|
-
"is-builtin-module": "^3.
|
|
110
|
-
"jest": "^27.
|
|
107
|
+
"glob": "^7.2.0",
|
|
108
|
+
"is-builtin-module": "^3.1.0",
|
|
109
|
+
"jest": "^27.4.7",
|
|
111
110
|
"jest-canvas-mock": "^2.3.1",
|
|
112
111
|
"jest-raw-loader": "^1.0.1",
|
|
113
112
|
"jsdom": "^19.0.0",
|
|
114
113
|
"json-stringify-pretty-compact": "^3.0.0",
|
|
115
|
-
"lodash": "^4.17.19",
|
|
116
|
-
"lodash.template": "^4.5.0",
|
|
117
114
|
"mapbox-gl-styles": "^2.0.2",
|
|
118
115
|
"minimist": "^1.2.5",
|
|
119
116
|
"mock-geolocation": "^1.0.11",
|
|
@@ -122,38 +119,38 @@
|
|
|
122
119
|
"npm-font-open-sans": "^1.1.0",
|
|
123
120
|
"npm-run-all": "^4.1.5",
|
|
124
121
|
"nyc": "^15.1.0",
|
|
125
|
-
"pdf-merger-js": "^3.2
|
|
126
|
-
"pixelmatch": "^5.1
|
|
122
|
+
"pdf-merger-js": "^3.3.2",
|
|
123
|
+
"pixelmatch": "^5.2.1",
|
|
127
124
|
"pngjs": "^6.0.0",
|
|
128
|
-
"postcss": "^8.
|
|
129
|
-
"postcss-cli": "^9.0
|
|
125
|
+
"postcss": "^8.4.5",
|
|
126
|
+
"postcss-cli": "^9.1.0",
|
|
130
127
|
"postcss-inline-svg": "^5.0.0",
|
|
131
|
-
"pretty-bytes": "^5.
|
|
132
|
-
"puppeteer": "^13.
|
|
128
|
+
"pretty-bytes": "^5.6.0",
|
|
129
|
+
"puppeteer": "^13.1.2",
|
|
133
130
|
"react": "^17.0.2",
|
|
134
131
|
"react-dom": "^17.0.2",
|
|
135
132
|
"request": "^2.88.0",
|
|
136
|
-
"rollup": "^2.
|
|
133
|
+
"rollup": "^2.66.1",
|
|
137
134
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
138
135
|
"rollup-plugin-terser": "^7.0.2",
|
|
139
136
|
"rollup-plugin-unassert": "^0.3.0",
|
|
140
137
|
"rollup-pluginutils": "^2.8.2",
|
|
141
138
|
"rw": "^1.3.3",
|
|
142
|
-
"selenium-webdriver": "^4.
|
|
139
|
+
"selenium-webdriver": "^4.1.1",
|
|
143
140
|
"semver": "^7.3.5",
|
|
144
141
|
"shuffle-seed": "^1.1.6",
|
|
145
142
|
"sinon": "^12.0.1",
|
|
146
|
-
"source-map-explorer": "^2.5.
|
|
143
|
+
"source-map-explorer": "^2.5.2",
|
|
147
144
|
"st": "^3.0.0",
|
|
148
145
|
"stylelint": "^14.3.0",
|
|
149
146
|
"stylelint-config-standard": "^24.0.0",
|
|
150
|
-
"tap-parser": "^10.0
|
|
151
|
-
"tape": "^5.
|
|
147
|
+
"tap-parser": "^10.1.0",
|
|
148
|
+
"tape": "^5.5.0",
|
|
152
149
|
"tape-filter": "^1.0.4",
|
|
153
150
|
"testem": "^3.6.0",
|
|
154
|
-
"ts-jest": "^27.
|
|
151
|
+
"ts-jest": "^27.1.3",
|
|
155
152
|
"ts-node": "^10.4.0",
|
|
156
|
-
"typescript": "^4.5.
|
|
153
|
+
"typescript": "^4.5.5"
|
|
157
154
|
},
|
|
158
155
|
"browser": {
|
|
159
156
|
"./rollup/build/tsc/src/util/web_worker.js": "./build/web_worker_replacement.js"
|
package/src/css/maplibre-gl.css
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
font: 12px/20px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
|
4
4
|
overflow: hidden;
|
|
5
5
|
position: relative;
|
|
6
|
-
-webkit-tap-highlight-color:
|
|
6
|
+
-webkit-tap-highlight-color: rgb(0 0 0 / 0%);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.maplibregl-canvas,
|
|
@@ -117,9 +117,9 @@
|
|
|
117
117
|
|
|
118
118
|
.maplibregl-ctrl-group:not(:empty),
|
|
119
119
|
.mapboxgl-ctrl-group:not(:empty) {
|
|
120
|
-
-moz-box-shadow: 0 0 2px
|
|
121
|
-
-webkit-box-shadow: 0 0 2px
|
|
122
|
-
box-shadow: 0 0 0 2px
|
|
120
|
+
-moz-box-shadow: 0 0 2px rgb(0 0 0 / 10%);
|
|
121
|
+
-webkit-box-shadow: 0 0 2px rgb(0 0 0 / 10%);
|
|
122
|
+
box-shadow: 0 0 0 2px rgb(0 0 0 / 10%);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
@media (-ms-high-contrast: active) {
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
.maplibregl-ctrl-group button:focus,
|
|
180
180
|
.mapboxgl-ctrl-attrib-button:focus,
|
|
181
181
|
.mapboxgl-ctrl-group button:focus {
|
|
182
|
-
box-shadow: 0 0 2px 2px
|
|
182
|
+
box-shadow: 0 0 2px 2px rgb(0 150 255 / 100%);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
.maplibregl-ctrl button:disabled,
|
|
@@ -194,12 +194,12 @@
|
|
|
194
194
|
|
|
195
195
|
.maplibregl-ctrl button:not(:disabled):hover,
|
|
196
196
|
.mapboxgl-ctrl button:not(:disabled):hover {
|
|
197
|
-
background-color:
|
|
197
|
+
background-color: rgb(0 0 0 / 5%);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
.maplibregl-ctrl-group button:focus:focus-visible,
|
|
201
201
|
.mapboxgl-ctrl-group button:focus:focus-visible {
|
|
202
|
-
box-shadow: 0 0 2px 2px
|
|
202
|
+
box-shadow: 0 0 2px 2px rgb(0 150 255 / 100%);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
.maplibregl-ctrl-group button:focus:not(:focus-visible),
|
|
@@ -519,7 +519,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
519
519
|
.maplibregl-ctrl.maplibregl-ctrl-attrib,
|
|
520
520
|
.mapboxgl-ctrl.mapboxgl-ctrl-attrib {
|
|
521
521
|
padding: 0 5px;
|
|
522
|
-
background-color:
|
|
522
|
+
background-color: rgb(255 255 255 / 50%);
|
|
523
523
|
margin: 0;
|
|
524
524
|
}
|
|
525
525
|
|
|
@@ -559,7 +559,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
559
559
|
cursor: pointer;
|
|
560
560
|
position: absolute;
|
|
561
561
|
background-image: svg-load("svg/maplibregl-ctrl-attrib.svg");
|
|
562
|
-
background-color:
|
|
562
|
+
background-color: rgb(255 255 255 / 50%);
|
|
563
563
|
width: 24px;
|
|
564
564
|
height: 24px;
|
|
565
565
|
box-sizing: border-box;
|
|
@@ -586,7 +586,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
586
586
|
|
|
587
587
|
.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button,
|
|
588
588
|
.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button {
|
|
589
|
-
background-color:
|
|
589
|
+
background-color: rgb(0 0 0 / 5%);
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
.maplibregl-ctrl-bottom-right > .maplibregl-ctrl-attrib.maplibregl-compact::after,
|
|
@@ -630,7 +630,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
630
630
|
|
|
631
631
|
.maplibregl-ctrl-attrib a,
|
|
632
632
|
.mapboxgl-ctrl-attrib a {
|
|
633
|
-
color:
|
|
633
|
+
color: rgb(0 0 0 / 75%);
|
|
634
634
|
text-decoration: none;
|
|
635
635
|
}
|
|
636
636
|
|
|
@@ -647,7 +647,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
647
647
|
|
|
648
648
|
.maplibregl-ctrl-scale,
|
|
649
649
|
.mapboxgl-ctrl-scale {
|
|
650
|
-
background-color:
|
|
650
|
+
background-color: rgb(255 255 255 / 75%);
|
|
651
651
|
font-size: 10px;
|
|
652
652
|
border-width: medium 2px 2px;
|
|
653
653
|
border-style: none solid solid;
|
|
@@ -789,7 +789,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
789
789
|
|
|
790
790
|
.maplibregl-popup-close-button:hover,
|
|
791
791
|
.mapboxgl-popup-close-button:hover {
|
|
792
|
-
background-color:
|
|
792
|
+
background-color: rgb(0 0 0 / 5%);
|
|
793
793
|
}
|
|
794
794
|
|
|
795
795
|
.maplibregl-popup-content,
|
|
@@ -797,7 +797,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
797
797
|
position: relative;
|
|
798
798
|
background: #fff;
|
|
799
799
|
border-radius: 3px;
|
|
800
|
-
box-shadow: 0 1px 2px
|
|
800
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 10%);
|
|
801
801
|
padding: 15px 10px;
|
|
802
802
|
pointer-events: auto;
|
|
803
803
|
}
|
|
@@ -884,7 +884,7 @@ a.mapboxgl-ctrl-logo.mapboxgl-compact {
|
|
|
884
884
|
top: -2px;
|
|
885
885
|
width: 19px;
|
|
886
886
|
box-sizing: border-box;
|
|
887
|
-
box-shadow: 0 0 3px
|
|
887
|
+
box-shadow: 0 0 3px rgb(0 0 0 / 35%);
|
|
888
888
|
}
|
|
889
889
|
|
|
890
890
|
@-webkit-keyframes maplibregl-user-location-dot-pulse {
|
|
@@ -30,19 +30,20 @@ describe('TileCache', () => {
|
|
|
30
30
|
keysExpected(cache, []);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
test('get without removing',
|
|
33
|
+
test('get without removing', done => {
|
|
34
34
|
const cache = new TileCache(10, () => {
|
|
35
|
-
|
|
35
|
+
done('test "get without removing" failed');
|
|
36
36
|
});
|
|
37
37
|
expect(cache.add(idA, tileA)).toBe(cache);
|
|
38
38
|
expect(cache.get(idA)).toBe(tileA);
|
|
39
39
|
keysExpected(cache, [idA]);
|
|
40
40
|
expect(cache.get(idA)).toBe(tileA);
|
|
41
|
+
done();
|
|
41
42
|
});
|
|
42
43
|
|
|
43
|
-
test('duplicate add',
|
|
44
|
+
test('duplicate add', done => {
|
|
44
45
|
const cache = new TileCache(10, () => {
|
|
45
|
-
|
|
46
|
+
done('test "duplicate add" failed');
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
cache.add(idA, tileA);
|
|
@@ -53,6 +54,7 @@ describe('TileCache', () => {
|
|
|
53
54
|
expect(cache.getAndRemove(idA)).toBe(tileA);
|
|
54
55
|
expect(cache.has(idA)).toBeTruthy();
|
|
55
56
|
expect(cache.getAndRemove(idA)).toBe(tileA2);
|
|
57
|
+
done();
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
test('expiry', () => {
|
|
@@ -9,13 +9,13 @@ import fixturesSource from '../../test/fixtures/source.json';
|
|
|
9
9
|
import {getMockDispatcher, getWrapDispatcher} from '../util/test/util';
|
|
10
10
|
import Map from '../ui/map';
|
|
11
11
|
|
|
12
|
-
function createSource(options, transformCallback
|
|
12
|
+
function createSource(options, transformCallback?, clearTiles = () => {}) {
|
|
13
13
|
const source = new VectorTileSource('id', options, getMockDispatcher(), options.eventedParent);
|
|
14
14
|
source.onAdd({
|
|
15
15
|
transform: {showCollisionBoxes: false},
|
|
16
16
|
_getMapId: () => 1,
|
|
17
17
|
_requestManager: new RequestManager(transformCallback),
|
|
18
|
-
style: {sourceCaches: {id: {clearTiles
|
|
18
|
+
style: {sourceCaches: {id: {clearTiles}}},
|
|
19
19
|
getPixelRatio() { return 1; }
|
|
20
20
|
} as any as Map);
|
|
21
21
|
|
|
@@ -343,4 +343,15 @@ describe('VectorTileSource', () => {
|
|
|
343
343
|
tiles: ['http://example2.com/{z}/{x}/{y}.png']
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
|
+
|
|
347
|
+
test('setTiles only clears the cache once the TileJSON has reloaded', done => {
|
|
348
|
+
const clearTiles = jest.fn();
|
|
349
|
+
const source = createSource({tiles: ['http://example.com/{z}/{x}/{y}.pbf']}, undefined, clearTiles);
|
|
350
|
+
source.setTiles(['http://example2.com/{z}/{x}/{y}.pbf']);
|
|
351
|
+
expect(clearTiles.mock.calls).toHaveLength(0);
|
|
352
|
+
source.once('data', () => {
|
|
353
|
+
expect(clearTiles.mock.calls).toHaveLength(1);
|
|
354
|
+
done();
|
|
355
|
+
});
|
|
356
|
+
});
|
|
346
357
|
});
|
|
@@ -97,6 +97,7 @@ class VectorTileSource extends Evented implements Source {
|
|
|
97
97
|
this._tileJSONRequest = loadTileJSON(this._options, this.map._requestManager, (err, tileJSON) => {
|
|
98
98
|
this._tileJSONRequest = null;
|
|
99
99
|
this._loaded = true;
|
|
100
|
+
this.map.style.sourceCaches[this.id].clearTiles();
|
|
100
101
|
if (err) {
|
|
101
102
|
this.fire(new ErrorEvent(err));
|
|
102
103
|
} else if (tileJSON) {
|
|
@@ -132,8 +133,6 @@ class VectorTileSource extends Evented implements Source {
|
|
|
132
133
|
|
|
133
134
|
callback();
|
|
134
135
|
|
|
135
|
-
const sourceCache = this.map.style.sourceCaches[this.id];
|
|
136
|
-
sourceCache.clearTiles();
|
|
137
136
|
this.load();
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -26,8 +26,6 @@ test('loadGlyphRange', done => {
|
|
|
26
26
|
const id = Number(key);
|
|
27
27
|
const glyph = result[id];
|
|
28
28
|
|
|
29
|
-
if (!glyph) return done.fail(); // appease flow
|
|
30
|
-
|
|
31
29
|
expect(glyph.id).toBe(Number(id));
|
|
32
30
|
expect(glyph.metrics).toBeTruthy();
|
|
33
31
|
expect(typeof glyph.metrics.width).toBe('number');
|
package/src/style/style.test.ts
CHANGED
|
@@ -48,6 +48,7 @@ function createGeoJSONSource() {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
class StubMap extends Evented {
|
|
51
|
+
style: Style;
|
|
51
52
|
transform: Transform;
|
|
52
53
|
private _requestManager: RequestManager;
|
|
53
54
|
|
|
@@ -68,6 +69,12 @@ class StubMap extends Evented {
|
|
|
68
69
|
|
|
69
70
|
const getStubMap = () => new StubMap() as any;
|
|
70
71
|
|
|
72
|
+
function createStyle(map = getStubMap()) {
|
|
73
|
+
const style = new Style(map);
|
|
74
|
+
map.style = style;
|
|
75
|
+
return style;
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
let sinonFakeXMLServer;
|
|
72
79
|
let sinonFakeServer;
|
|
73
80
|
let _self;
|
|
@@ -258,7 +265,7 @@ describe('Style#loadJSON', () => {
|
|
|
258
265
|
});
|
|
259
266
|
|
|
260
267
|
test('creates sources', done => {
|
|
261
|
-
const style =
|
|
268
|
+
const style = createStyle();
|
|
262
269
|
|
|
263
270
|
style.on('style.load', () => {
|
|
264
271
|
expect(style.sourceCaches['mapLibre'] instanceof SourceCache).toBeTruthy();
|
|
@@ -276,7 +283,7 @@ describe('Style#loadJSON', () => {
|
|
|
276
283
|
});
|
|
277
284
|
|
|
278
285
|
test('creates layers', done => {
|
|
279
|
-
const style =
|
|
286
|
+
const style = createStyle();
|
|
280
287
|
|
|
281
288
|
style.on('style.load', () => {
|
|
282
289
|
expect(style.getLayer('fill') instanceof StyleLayer).toBeTruthy();
|
|
@@ -302,7 +309,7 @@ describe('Style#loadJSON', () => {
|
|
|
302
309
|
test('transforms sprite json and image URLs before request', done => {
|
|
303
310
|
const map = getStubMap();
|
|
304
311
|
const transformSpy = jest.spyOn(map._requestManager, 'transformRequest');
|
|
305
|
-
const style =
|
|
312
|
+
const style = createStyle(map);
|
|
306
313
|
|
|
307
314
|
style.on('style.load', () => {
|
|
308
315
|
expect(transformSpy).toHaveBeenCalledTimes(2);
|
|
@@ -319,7 +326,7 @@ describe('Style#loadJSON', () => {
|
|
|
319
326
|
});
|
|
320
327
|
|
|
321
328
|
test('emits an error on non-existant vector source layer', done => {
|
|
322
|
-
const style =
|
|
329
|
+
const style = createStyle();
|
|
323
330
|
style.loadJSON(createStyleJSON({
|
|
324
331
|
sources: {
|
|
325
332
|
'-source-id-': {type: 'vector', tiles: []}
|
|
@@ -407,7 +414,7 @@ describe('Style#_remove', () => {
|
|
|
407
414
|
|
|
408
415
|
describe('Style#update', () => {
|
|
409
416
|
test('on error', done => {
|
|
410
|
-
const style =
|
|
417
|
+
const style = createStyle();
|
|
411
418
|
style.loadJSON({
|
|
412
419
|
'version': 8,
|
|
413
420
|
'sources': {
|
|
@@ -449,7 +456,7 @@ describe('Style#setState', () => {
|
|
|
449
456
|
});
|
|
450
457
|
|
|
451
458
|
test('do nothing if there are no changes', done => {
|
|
452
|
-
const style =
|
|
459
|
+
const style = createStyle();
|
|
453
460
|
style.loadJSON(createStyleJSON());
|
|
454
461
|
jest.spyOn(style, 'addLayer').mockImplementation(() => done('test failed'));
|
|
455
462
|
jest.spyOn(style, 'removeLayer').mockImplementation(() => done('test failed'));
|
|
@@ -574,7 +581,7 @@ describe('Style#addSource', () => {
|
|
|
574
581
|
});
|
|
575
582
|
|
|
576
583
|
test('fires "data" event', done => {
|
|
577
|
-
const style =
|
|
584
|
+
const style = createStyle();
|
|
578
585
|
style.loadJSON(createStyleJSON());
|
|
579
586
|
const source = createSource();
|
|
580
587
|
style.once('data', () => { done(); });
|
|
@@ -585,7 +592,7 @@ describe('Style#addSource', () => {
|
|
|
585
592
|
});
|
|
586
593
|
|
|
587
594
|
test('throws on duplicates', done => {
|
|
588
|
-
const style =
|
|
595
|
+
const style = createStyle();
|
|
589
596
|
style.loadJSON(createStyleJSON());
|
|
590
597
|
const source = createSource();
|
|
591
598
|
style.on('style.load', () => {
|
|
@@ -607,7 +614,7 @@ describe('Style#addSource', () => {
|
|
|
607
614
|
done();
|
|
608
615
|
}
|
|
609
616
|
};
|
|
610
|
-
const style =
|
|
617
|
+
const style = createStyle();
|
|
611
618
|
style.loadJSON(createStyleJSON({
|
|
612
619
|
layers: [{
|
|
613
620
|
id: 'background',
|
|
@@ -795,7 +802,7 @@ describe('Style#addLayer', () => {
|
|
|
795
802
|
});
|
|
796
803
|
|
|
797
804
|
test('throws on non-existant vector source layer', done => {
|
|
798
|
-
const style =
|
|
805
|
+
const style = createStyle();
|
|
799
806
|
style.loadJSON(createStyleJSON({
|
|
800
807
|
sources: {
|
|
801
808
|
// At least one source must be added to trigger the load event
|
|
@@ -864,7 +871,7 @@ describe('Style#addLayer', () => {
|
|
|
864
871
|
});
|
|
865
872
|
|
|
866
873
|
test('reloads source', done => {
|
|
867
|
-
const style =
|
|
874
|
+
const style = createStyle();
|
|
868
875
|
style.loadJSON(extend(createStyleJSON(), {
|
|
869
876
|
'sources': {
|
|
870
877
|
'mapLibre': {
|
|
@@ -891,7 +898,7 @@ describe('Style#addLayer', () => {
|
|
|
891
898
|
});
|
|
892
899
|
|
|
893
900
|
test('#3895 reloads source (instead of clearing) if adding this layer with the same type, immediately after removing it', done => {
|
|
894
|
-
const style =
|
|
901
|
+
const style = createStyle();
|
|
895
902
|
style.loadJSON(extend(createStyleJSON(), {
|
|
896
903
|
'sources': {
|
|
897
904
|
'mapLibre': {
|
|
@@ -928,7 +935,7 @@ describe('Style#addLayer', () => {
|
|
|
928
935
|
});
|
|
929
936
|
|
|
930
937
|
test('clears source (instead of reloading) if adding this layer with a different type, immediately after removing it', done => {
|
|
931
|
-
const style =
|
|
938
|
+
const style = createStyle();
|
|
932
939
|
style.loadJSON(extend(createStyleJSON(), {
|
|
933
940
|
'sources': {
|
|
934
941
|
'mapLibre': {
|
package/src/ui/camera.test.ts
CHANGED
|
@@ -756,9 +756,9 @@ describe('#easeTo', () => {
|
|
|
756
756
|
const camera = createCamera();
|
|
757
757
|
|
|
758
758
|
camera
|
|
759
|
-
.on('zoomstart', () => {
|
|
760
|
-
.on('zoom', () => {
|
|
761
|
-
.on('zoomend', () => {
|
|
759
|
+
.on('zoomstart', () => { done('zoomstart failed'); })
|
|
760
|
+
.on('zoom', () => { done('zoom failed'); })
|
|
761
|
+
.on('zoomend', () => { done('zoomend failed'); })
|
|
762
762
|
.on('moveend', () => { done(); });
|
|
763
763
|
|
|
764
764
|
camera.easeTo({center: [100, 0], duration: 0});
|
|
@@ -1545,7 +1545,7 @@ describe('#flyTo', () => {
|
|
|
1545
1545
|
.on('moveend', () => {
|
|
1546
1546
|
endTime = new Date();
|
|
1547
1547
|
timeDiff = endTime - startTime;
|
|
1548
|
-
expect(timeDiff).toBeLessThan(
|
|
1548
|
+
expect(timeDiff).toBeLessThan(30);
|
|
1549
1549
|
done();
|
|
1550
1550
|
});
|
|
1551
1551
|
|
|
@@ -34,6 +34,7 @@ function createSource(options, logoRequired) {
|
|
|
34
34
|
_skuToken: '1234567890123',
|
|
35
35
|
canonicalizeTileset: tileJSON => tileJSON.tiles
|
|
36
36
|
},
|
|
37
|
+
style: {sourceCaches: {id: {clearTiles() {}}}},
|
|
37
38
|
transform: {angle: 0, pitch: 0, showCollisionBoxes: false},
|
|
38
39
|
_getMapId: () => 1
|
|
39
40
|
}as any as Map);
|
|
@@ -46,7 +46,7 @@ describe('ScrollZoomHandler', () => {
|
|
|
46
46
|
map.remove();
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
test('Zooms for single mouse wheel tick with non-magical deltaY',
|
|
49
|
+
test('Zooms for single mouse wheel tick with non-magical deltaY', done => {
|
|
50
50
|
const browserNow = jest.spyOn(browser, 'now');
|
|
51
51
|
const now = 1555555555555;
|
|
52
52
|
browserNow.mockReturnValue(now);
|
|
@@ -60,6 +60,7 @@ describe('ScrollZoomHandler', () => {
|
|
|
60
60
|
simulate.wheel(map.getCanvas(), {type: 'wheel', deltaY: -20});
|
|
61
61
|
map.on('zoomstart', () => {
|
|
62
62
|
map.remove();
|
|
63
|
+
done();
|
|
63
64
|
});
|
|
64
65
|
});
|
|
65
66
|
|