fix map init on block row add fix geocoding reverse for map field in block row
This commit is contained in:
parent
0a9ba667cf
commit
b7ecac9b42
|
@ -687,6 +687,7 @@ $(function() {
|
|||
const $new_blockrow = $new_block.find('.BlockSubWidget').last();
|
||||
add_js_behaviours($('[data-field-id="' + block_id + '"]'));
|
||||
$('form').trigger('wcs:block-row-added');
|
||||
$(document).trigger('wcs:maps-init');
|
||||
if ($new_block.find('[data-live-source]')) {
|
||||
$('form div[data-live-source]').parents('form').trigger('wcs:change', {modified_field: 'init'});
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ $(function() {
|
|||
init_sync_from_template_address();
|
||||
});
|
||||
$(document).on('set-geolocation', function(event, coords, options) {
|
||||
var widget_name = $(event.target).parents('div.widget').data('widget-name');
|
||||
$.getJSON(WCS_ROOT_URL + '/api/reverse-geocoding?lat=' + coords.lat + '&lon=' + coords.lng, function(data) {
|
||||
unset_sync_callback()
|
||||
if (data.err) return;
|
||||
|
@ -116,7 +117,7 @@ $(function() {
|
|||
}
|
||||
|
||||
if (typeof(options) == 'undefined' || !options.force_house_number === false || data.address.house_number) {
|
||||
geoloc_prefill('house', data.address.house_number);
|
||||
geoloc_prefill('house', data.address.house_number, widget_name);
|
||||
}
|
||||
var number_and_street = null;
|
||||
var street = data.address.road;
|
||||
|
@ -131,16 +132,16 @@ $(function() {
|
|||
} else if (!street && data.address.park) {
|
||||
street = data.address.park;
|
||||
}
|
||||
geoloc_prefill('road', street);
|
||||
geoloc_prefill('road', street, widget_name);
|
||||
if (street && data.address.house_number) {
|
||||
number_and_street = data.address.house_number + ' ' + street;
|
||||
} else {
|
||||
number_and_street = street;
|
||||
}
|
||||
geoloc_prefill('number-and-street', number_and_street);
|
||||
geoloc_prefill('postcode', data.address.postcode);
|
||||
geoloc_prefill('city', data.address.village || data.address.town || data.address.city || data.address.locality || data.address.municipality || data.address.county);
|
||||
geoloc_prefill('country', data.address.country);
|
||||
geoloc_prefill('number-and-street', number_and_street, widget_name);
|
||||
geoloc_prefill('postcode', data.address.postcode, widget_name);
|
||||
geoloc_prefill('city', data.address.village || data.address.town || data.address.city || data.address.locality || data.address.municipality || data.address.county, widget_name);
|
||||
geoloc_prefill('country', data.address.country, widget_name);
|
||||
$(document).trigger('wcs:set-last-auto-save');
|
||||
set_sync_callback()
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue