Skip to content

Commit bacf58a

Browse files
lesbaaLes Moffat
andauthored
RD-1226 style not done loading (#253)
* hotfix: update changelog and readme with correct links to docs (#246) Co-authored-by: Les Moffat <[email protected]> * RD-1226 Bug is reproducible * RD-1226 Implement fix for "Style Not Done loading" error when Image is used with spacebox. * RD-1226 Update changelog * RD-1226 Tidy up demos * RD-1226 Appease linter and typecheck * RD-1226 Remove unneeded changes * RD-1226 Fix logic in setSpaceFromStyle --------- Co-authored-by: Les Moffat <[email protected]>
1 parent 842159e commit bacf58a

File tree

6 files changed

+138
-114
lines changed

6 files changed

+138
-114
lines changed

CHANGELOG.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
- `ImageViewerMarker` class added. `ImageViewer`can now have markers positioned in image pixels.
1313

1414

15-
### 🐛 Bug fixes
16-
- fixes a bug where `map.getProjection()` did not return a value when default projection was used
15+
### 🐛 Bug Fixes
16+
- Fixes a bug where `map.getProjection()` did not return a value when default projection was used
17+
- Fixes a bug where "Style Not Done Loading" error is thrown when an Image is used in conjunction with Spacebox.
18+
- Fixes a bug where switching between remote styles causes flickering in Halo.
1719

1820
### ⚙️ Others
1921
- Right to left text is now opt-out. `rtlTextPlugin` can be passed in the constructor options to opt-out of installing the RTL text-plugin or install a different RTL text-plugin. Without this option the behaviour will remain the same.
@@ -25,11 +27,12 @@
2527
- Adds `enableHaloAnimations`, `enableSpaceAnimations`, `disableHaloAnimations`, `disableSpaceAnimations` to Map instance for toggling halo and space animations.
2628
- Adds custom controls that can be styled however you wish and can do whatever you need, in both declarative (auto-detected) and programmatic way. See [the section in the readme](https://github.com/maptiler/maptiler-sdk-js#-custom-controls) for more info.
2729

28-
### 🐛 Bug fixes
29-
- fixes a bug on `halo` where sharp edged stops cause noise to surface when scaled down.
30-
- fixes bug where space would not load correctly when style is a URI.
31-
- fixes a bug in the UMD module where space crashes when only a color is set.
32-
- fixes a bug when `space: true` and no style is passed, `space` becomes unset.
30+
### 🐛 Bug Fixes
31+
- Fixes a bug on `halo` where sharp edged stops cause noise to surface when scaled down.
32+
- Fixes bug where space would not load correctly when style is a URI.
33+
- Fixes a bug in the UMD module where space crashes when only a color is set.
34+
- Fixes a bug when `space: true` and no style is passed, `space` becomes unset.
35+
3336

3437
⚙️ Others
3538
- Removes superfluous dependencies from package.json
@@ -39,7 +42,7 @@
3942
### ✨ Features and improvements
4043
- Version Bump @maptiler/client to 2.5.0 adding `at`, `batch`, `computeOn`, `canParsePixelData` functions for working with elevations.
4144

42-
### 🐛 Bug fixes
45+
### 🐛 Bug Fixes
4346
- Includes workaround where internal event is not fired correctly and causes breaking of space box.
4447

4548
### Others
@@ -50,7 +53,7 @@
5053
### ✨ Features and improvements
5154
- None
5255

53-
### 🐛 Bug fixes
56+
### 🐛 Bug Fixes
5457
- Fixes a bug that breaks spacebox when projection is changed in style.json
5558

5659
### Others
@@ -61,7 +64,7 @@
6164
### ✨ Features and improvements
6265
- None
6366

64-
### 🐛 Bug fixes
67+
### 🐛 Bug Fixes
6568
- Fixes bug where terrain does not load when `map.enableTerrain()` is called directly after `.flyTo`
6669
- Adds `StyleDefinitionWithMetadata` as an accepted type to `setStyle` ([#216](https://github.com/maptiler/maptiler-sdk-js/issues/216))
6770
- Adds condition to log calls in `extractCustomLayerStyle` ([#216](https://github.com/maptiler/maptiler-sdk-js/issues/216))
@@ -86,7 +89,7 @@ constructor _or_ via `setSpace` or `setHalo` methods _or_ via incoming MT style
8689
### ✨ Features and improvements
8790
- Update Maplibre to 5.6.0
8891

89-
### 🐛 Bug fixes
92+
### 🐛 Bug Fixes
9093
- Fix for [RD-900](https://maptiler.atlassian.net/browse/RD-900?atlOrigin=eyJpIjoiOTRjZGRhYjg2Y2JhNGY2NGI2NzM2M2E1MGNkNjBmYWYiLCJwIjoiaiJ9)
9194

9295
### Others
@@ -103,7 +106,7 @@ constructor _or_ via `setSpace` or `setHalo` methods _or_ via incoming MT style
103106
### ✨ Features and improvements
104107
None
105108

106-
### 🐛 Bug fixes
109+
### 🐛 Bug Fixes
107110
- Fixes incorrect exports of some types from sdk helper functions.
108111

109112
### 🔧 Others
@@ -113,7 +116,7 @@ None
113116
### ✨ Features and improvements
114117
None
115118

116-
### 🐛 Bug fixes
119+
### 🐛 Bug Fixes
117120
- [RD-902](https://maptiler.atlassian.net/browse/RD-902?atlOrigin=eyJpIjoiNGM2NGQxNzg0ZjEzNGJlMGI3M2Y1YTM3YTIyNjdkMDkiLCJwIjoiaiJ9) Changes to use default import for maplibre-gl as it uses commonjs modules under the hood.
118121

119122
### 🔧 Others
@@ -132,7 +135,7 @@ None
132135
### ✨ Features and improvements
133136
None
134137

135-
### 🐛 Bug fixes
138+
### 🐛 Bug Fixes
136139
None
137140

138141
### 🔧 Others
@@ -142,7 +145,7 @@ Version bump for maptiler-client-js
142145
### ✨ Features and improvements
143146
Updates MapTiler Client JS version to include new MapStyles
144147

145-
### 🐛 Bug fixes
148+
### 🐛 Bug Fixes
146149
None
147150

148151
### 🔧 Others
@@ -152,7 +155,7 @@ None
152155
### ✨ Features and improvements
153156
None
154157

155-
### 🐛 Bug fixes
158+
### 🐛 Bug Fixes
156159
Fixes a bug that accesses undefined `projection` object in `Map.getProjection` method
157160

158161
### 🔧 Others
@@ -162,7 +165,7 @@ None
162165
### ✨ Features and improvements
163166
None
164167

165-
### 🐛 Bug fixes
168+
### 🐛 Bug Fixes
166169
None
167170

168171
### 🔧 Others
@@ -180,7 +183,7 @@ Restructuring of repo, additon of tests to check consistency of library exports.
180183
* Globe projection support
181184
* `MaptilerProjectionControl` to toggle Globe/Mercator projection
182185

183-
### 🐛 Bug fixes
186+
### 🐛 Bug Fixes
184187
* Navigation now relies on `Map` methods instead of `Transform` methods for bearing due to globe projection being available
185188

186189
### 🔧 Others

demos/public/XX-scratch-pad.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77

88
<title>Document</title>
99
<style>
10-
body { margin: 0; padding: 0; }
10+
body { margin: 0; padding: 0; }
1111
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
1212
.button { position: absolute; top: 10px; left: 10px; z-index: 10; }
1313
</style>
1414
</head>
1515
<body>
16-
<button class="button">change language</button>
1716
<div id="map"></div>
1817
<script type="module" src="/src/XX-scratch-pad.ts"></script>
1918
</body>

demos/src/01-simple.ts

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,37 @@ setupMapTilerApiKey({ config });
66

77
const container = document.getElementById("map")!;
88

9-
const map = new Map({
10-
container,
11-
style: MapStyle.OUTDOOR.DARK,
12-
hash: true,
13-
geolocate: true,
14-
scaleControl: true,
15-
fullscreenControl: true,
16-
terrainControl: true,
17-
projectionControl: true,
18-
});
19-
20-
const styleDropDown = document.getElementById("mapstyles-picker") as HTMLOptionElement;
21-
22-
styleDropDown.onchange = () => {
23-
map.setStyle(styleDropDown.value);
24-
};
25-
26-
Object.keys(MapStyle).forEach((s) => {
27-
const styleOption = document.createElement("option");
28-
// @ts-expect-error we know that `id` is private.
29-
styleOption.value = MapStyle[s as keyof typeof MapStyle].DEFAULT.id;
30-
styleOption.innerHTML = s.replace("_", " ").toLowerCase();
31-
styleDropDown.appendChild(styleOption);
32-
});
9+
async function main() {
10+
const map = new Map({
11+
container,
12+
style: MapStyle.OUTDOOR.DARK,
13+
hash: true,
14+
geolocate: false,
15+
scaleControl: true,
16+
fullscreenControl: true,
17+
terrainControl: true,
18+
projectionControl: true,
19+
projection: "globe",
20+
space: true,
21+
halo: true,
22+
zoom: 1,
23+
});
24+
25+
const styleDropDown = document.getElementById("mapstyles-picker") as HTMLOptionElement;
26+
27+
styleDropDown.onchange = () => {
28+
map.setStyle(styleDropDown.value);
29+
};
30+
31+
await map.onReadyAsync();
32+
33+
Object.keys(MapStyle).forEach((s) => {
34+
const styleOption = document.createElement("option");
35+
// @ts-expect-error we know that `id` is private.
36+
styleOption.value = MapStyle[s as keyof typeof MapStyle].DEFAULT.id;
37+
styleOption.innerHTML = s.replace("_", " ").toLowerCase();
38+
styleDropDown.appendChild(styleOption);
39+
});
40+
}
41+
42+
main();

demos/src/XX-scratch-pad.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
import "../../src/style/style_template.css";
1+
// This file is intended for quick testing or development. Please do not commit changes to this file.
2+
23
import { Map, MapStyle, config } from "../../src/index";
34
import { addPerformanceStats, setupMapTilerApiKey } from "./demo-utils";
45

56
addPerformanceStats();
67
setupMapTilerApiKey({ config });
78

8-
const container = document.getElementById("map") as HTMLDivElement;
9+
const container = document.getElementById("map")!;
10+
11+
async function main() {
12+
const map = new Map({
13+
container,
14+
style: MapStyle.OUTDOOR.DARK,
15+
hash: true,
16+
geolocate: true,
17+
scaleControl: true,
18+
fullscreenControl: true,
19+
terrainControl: true,
20+
projectionControl: true,
21+
projection: "globe",
22+
halo: true,
23+
space: true,
24+
zoom: 10,
25+
});
926

10-
const map = new Map({
11-
container,
12-
style: MapStyle.STREETS.DEFAULT,
13-
hash: true,
14-
geolocate: true,
15-
scaleControl: true,
16-
fullscreenControl: true,
17-
terrain: true,
18-
projectionControl: true,
19-
});
27+
await map.onReadyAsync();
28+
}
2029

21-
document.getElementsByTagName("button")[0].addEventListener("click", () => {
22-
map.setStyle(MapStyle.TONER.DEFAULT);
23-
map.flyTo({ zoom: 12, center: [-7.39468, 39.32507] });
24-
});
30+
void main();

0 commit comments

Comments
 (0)