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
|
// If they click the map at all, they are not interested in their location anymore
|
||||||
locationCheckedChanged(false);
|
locationCheckedChanged(false);
|
||||||
});
|
});
|
||||||
map.on('click', onMapClick);
|
map.on('click', (e) => {
|
||||||
|
onMapClick({
|
||||||
|
latlng: e.latlng,
|
||||||
|
event: 'click'
|
||||||
|
});
|
||||||
|
});
|
||||||
map.on('locationfound', (e) => {
|
map.on('locationfound', (e) => {
|
||||||
dispatch('locationfound', e.detail);
|
dispatch('locationfound', e.detail);
|
||||||
});
|
});
|
||||||
@ -68,17 +73,23 @@
|
|||||||
let geocoder = new leafletControlGeocoder.Geocoder({ defaultMarkGeocode: false })
|
let geocoder = new leafletControlGeocoder.Geocoder({ defaultMarkGeocode: false })
|
||||||
.on('markgeocode', function (e) {
|
.on('markgeocode', function (e) {
|
||||||
console.log('Marked geocode:', e);
|
console.log('Marked geocode:', e);
|
||||||
|
|
||||||
|
// They found a location. Disable location polling
|
||||||
|
locationCheckedChanged(false);
|
||||||
|
|
||||||
onMapClick({
|
onMapClick({
|
||||||
latlng: {
|
latlng: {
|
||||||
lat: e.geocode.center.lat,
|
lat: e.geocode.center.lat,
|
||||||
lng: e.geocode.center.lng
|
lng: e.geocode.center.lng
|
||||||
}
|
},
|
||||||
|
event: 'markgeocode'
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
leaflet
|
leaflet
|
||||||
.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
maxZoom: 19,
|
||||||
attribution:
|
attribution:
|
||||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
})
|
})
|
||||||
|
@ -32,7 +32,13 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onMapClick = (e) => {
|
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 () => {
|
let init = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user