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