Update address input based on marker drag
This commit is contained in:
parent
96e3441556
commit
de3a1d23b6
3 changed files with 20 additions and 12 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue