Skip to content

Commit

Permalink
improved the typing in the interactive map
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Oct 2, 2022
1 parent ea7bc9c commit 733d487
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions webclient/src/components/DetailsInteractiveMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ const coord_picker = ref({
});
const initialLoaded = ref(false);
type Coord = {
coords: {
lat: number | undefined;
lon: number | undefined;
};
};
function confirmLocationPicker() {
// add the current edits to the feedback
const currentEdits = getLocalStorageWithExpiry("coordinate-feedback", {});
const currentEdits = getLocalStorageWithExpiry<{[index: string]: Coord}>("feedback-coords", {});
const location = marker2.value?.getLngLat();
currentEdits[this.state.data.id] = {
coords: { lat: location.lat, lon: location.lng },
currentEdits[state.data!.id] = {
coords: { lat: location?.lat, lon: location?.lng },
};
// save to local storage with ttl of 12h (garbage-collected on next read)
setLocalStorageWithExpiry("feedback-coords", currentEdits, 12);
Expand Down Expand Up @@ -300,7 +306,9 @@ function setOverlayImage(
if (map.value!.getLayer("overlay-bg"))
map.value!.setLayoutProperty("overlay-bg", "visibility", "none");
} else {
const source = map.value!.getSource("overlay-src") as ImageSource | undefined;
const source = map.value!.getSource("overlay-src") as
| ImageSource
| undefined;
if (!source)
map.value!.addSource("overlay-src", {
type: "image",
Expand All @@ -313,7 +321,9 @@ function setOverlayImage(
coordinates: coords,
});
const layer = map.value!.getLayer("overlay-layer") as BackgroundLayer | undefined;
const layer = map.value!.getLayer("overlay-layer") as
| BackgroundLayer
| undefined;
if (!layer) {
map.value!.addLayer({
id: "overlay-bg",
Expand Down

0 comments on commit 733d487

Please sign in to comment.