geolocation: don't empty housenumber if not found in reverse (#50709)

This commit is contained in:
Lauréline Guérin 2021-02-04 15:41:21 +01:00
parent 09b7161ae9
commit 5d03ea1f89
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 5 additions and 3 deletions

View File

@ -24,10 +24,12 @@ function geoloc_prefill(element_type, element_value)
}
}
$(document).on('set-geolocation', function(event, coords) {
$(document).on('set-geolocation', function(event, coords, options) {
$.getJSON(WCS_ROOT_URL + '/api/reverse-geocoding?lat=' + coords.lat + '&lon=' + coords.lng, function(data) {
unset_sync_callback()
geoloc_prefill('house', data.address.house_number);
if (typeof(options) == 'undefined' || !options.force_house_number === false || data.address.house_number) {
geoloc_prefill('house', data.address.house_number);
}
var number_and_street = null;
var street = data.address.road;
if (!street && data.address.pedestrian) {
@ -149,7 +151,7 @@ function geoloc_prefill(element_type, element_value)
map.marker = L.marker([0, 0]);
map.marker.addTo(map);
}
$map.trigger('set-geolocation', coords, {'trigger': false});
$map.trigger('set-geolocation', [coords, {'trigger': false, 'force_house_number': false}]);
$form[0].wait_for_changes = false;
}
});