Improve location finding from search
This commit is contained in:
parent
43f4b44cb9
commit
df9dd7f32a
@ -48,7 +48,12 @@
|
||||
// If they click the map at all, they are not interested in their location anymore
|
||||
locationCheckedChanged(false);
|
||||
});
|
||||
map.on('click', onMapClick);
|
||||
map.on('click', (e) => {
|
||||
onMapClick({
|
||||
latlng: e.latlng,
|
||||
event: 'click'
|
||||
});
|
||||
});
|
||||
map.on('locationfound', (e) => {
|
||||
dispatch('locationfound', e.detail);
|
||||
});
|
||||
@ -68,17 +73,23 @@
|
||||
let geocoder = new leafletControlGeocoder.Geocoder({ defaultMarkGeocode: false })
|
||||
.on('markgeocode', function (e) {
|
||||
console.log('Marked geocode:', e);
|
||||
|
||||
// They found a location. Disable location polling
|
||||
locationCheckedChanged(false);
|
||||
|
||||
onMapClick({
|
||||
latlng: {
|
||||
lat: e.geocode.center.lat,
|
||||
lng: e.geocode.center.lng
|
||||
}
|
||||
},
|
||||
event: 'markgeocode'
|
||||
});
|
||||
})
|
||||
.addTo(map);
|
||||
|
||||
leaflet
|
||||
.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
})
|
||||
|
@ -32,7 +32,13 @@
|
||||
};
|
||||
|
||||
const onMapClick = (e) => {
|
||||
updateAddr(wasm.call.EncodedAddress.from_coordinate(`${e.latlng.lat}, ${e.latlng.lng}`), false);
|
||||
// If they found this from a search, we should zoom there
|
||||
let fromTextInput = e.event == 'markgeocode';
|
||||
|
||||
updateAddr(
|
||||
wasm.call.EncodedAddress.from_coordinate(`${e.latlng.lat}, ${e.latlng.lng}`),
|
||||
fromTextInput
|
||||
);
|
||||
};
|
||||
|
||||
let init = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user