Update address input based on marker drag

This commit is contained in:
Eli Ribble 2026-01-30 22:00:43 +00:00
parent 96e3441556
commit de3a1d23b6
No known key found for this signature in database
3 changed files with 20 additions and 12 deletions

View file

@ -123,9 +123,7 @@ class AddressInput extends HTMLElement {
el.addEventListener('click', e => {
const index = parseInt(el.dataset.index);
const suggestion = suggestions[index];
this.value = suggestion.properties.full_address;
this._suggestions.innerHTML = '';
this.SetValue(suggestion);
// Dispatch custom event
this.dispatchEvent(new CustomEvent('address-selected', {
bubbles: true,
@ -194,6 +192,11 @@ class AddressInput extends HTMLElement {
this._suggestions.innerHTML = '';
}
}
SetValue(suggestion) {
this.value = suggestion.properties.full_address;
this._suggestions.innerHTML = '';
}
}
customElements.define('address-input', AddressInput);

View file

@ -7,5 +7,5 @@ async function geocodeReverse(MAPBOX_ACCESS_TOKEN, lngLat) {
console.warn("No results for reverse geocode");
return;
}
const match = data.features[0];
return data
}