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

Fix: Fixed type errors revealed by Cypress. #167

Merged
merged 3 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", () => {
designorant marked this conversation as resolved.
Show resolved Hide resolved
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