Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #167 from ONSdigital/fix/invalid-type-347
Browse files Browse the repository at this point in the history
Fix: Fixed type errors revealed by Cypress.
  • Loading branch information
James-Nitron authored Mar 2, 2022
2 parents 4aeef25 + 5221a8a commit 819d4e6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 49 deletions.
72 changes: 37 additions & 35 deletions src/ui/map/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,43 @@
link.href = "https://unpkg.com/mapbox-gl/dist/mapbox-gl.css";
link.onload = () => {
map = new Map({
container,
style: mapstyle,
minZoom: minzoom,
maxZoom: maxzoom,
maxBounds: outerMapBounds,
attributionControl: false,
...options,
});
map.addControl(new NavigationControl());
map.addControl(new AttributionControl(), "bottom-left");
map.fitBounds(bounds, { padding: 20 });
// Get initial zoom level
map.on("load", () => {
debouncedMapZoomBBoxStore(map);
zoom = map.getZoom();
});
map.on("render", () => {
map.resize();
});
// Update zoom level when the view zooms
map.on("zoom", () => {
debouncedMapZoomBBoxStore(map);
zoom = map.getZoom();
});
map.on("drag", () => {
debouncedMapZoomBBoxStore(map);
});
if (container) {
map = new Map({
container,
style: mapstyle,
minZoom: minzoom,
maxZoom: maxzoom,
maxBounds: outerMapBounds,
attributionControl: false,
...options,
});
map.addControl(new NavigationControl());
map.addControl(new AttributionControl(), "bottom-left");
map.fitBounds(bounds, { padding: 20 });
// Get initial zoom level
map.on("load", () => {
debouncedMapZoomBBoxStore(map);
zoom = map.getZoom();
});
map.on("render", () => {
map.resize();
});
// Update zoom level when the view zooms
map.on("zoom", () => {
debouncedMapZoomBBoxStore(map);
zoom = map.getZoom();
});
map.on("drag", () => {
debouncedMapZoomBBoxStore(map);
});
}
};
document.head.appendChild(link);
Expand Down
20 changes: 7 additions & 13 deletions src/ui/map/TileSet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@
}
}
// watches for isMapLoaded then runs the addSource method
function isMapLoaded() {
if (map.isStyleLoaded(id)) {
addSource();
} else {
setTimeout(() => {
isMapLoaded();
}, 100);
}
}
/* Waits for style to load then runs the addSource method.
Warning: style.load is not documentated as never intended to be a public API.
More information can be found here: https://github.com/mapbox/mapbox-gl-js/issues/2268
*/
map.on("style.load", () => {
addSource();
});
// Set optional source properties
if (minzoom) {
Expand Down Expand Up @@ -97,9 +94,6 @@
isSourceLoaded();
}
}
// kicks off the chain
$: map && isMapLoaded();
</script>

{#if loaded}
Expand Down
5 changes: 4 additions & 1 deletion src/ui/ons/ONSAutosuggest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
function onKeyUp(e) {
if (e.keyCode === 13) {
autosuggestValue = document.querySelector(".ons-autosuggest-input__option--focused").innerText;
const input = document.querySelector(".ons-autosuggest-input__option--focused");
if (input) {
autosuggestValue = input.innerText;
}
}
}
</script>
Expand Down

0 comments on commit 819d4e6

Please sign in to comment.