fix: broken value display for coords in LocationSelect
This commit is contained in:
@ -53,21 +53,26 @@
|
||||
|
||||
async function getCoordLabel(value: `${number},${number}`) {
|
||||
const splitter = value.split(",");
|
||||
console.log(`getCoordLabel(${value})`);
|
||||
const res = await reverseGeocode({
|
||||
lat: parseFloat(splitter[0]),
|
||||
lon: parseFloat(splitter[1]),
|
||||
});
|
||||
if (res.length == 0) return "<unknown>";
|
||||
const feature = res[0];
|
||||
console.log(`getCoordLabel(${value}) == ${feature.properties.name}`);
|
||||
return feature.properties.name;
|
||||
}
|
||||
|
||||
const selectedValue = $derived(
|
||||
new Promise((r) => {
|
||||
r(
|
||||
locations.find((f) => f.value === value)?.label ||
|
||||
getCoordLabel(value).then((v) => r(v)),
|
||||
);
|
||||
if (locations.find((f) => f.value === value)) {
|
||||
return r(locations.find((f) => f.value === value)?.label);
|
||||
}
|
||||
getCoordLabel(value).then((v) => r(v));
|
||||
}).then((label) => {
|
||||
console.log("[LocationSelect] selectedValue", { value, label });
|
||||
return label;
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user