address: fix bug when editing address: update localisation and addressreferenceId + better update of the map in edition

This commit is contained in:
nobohan 2022-04-27 10:38:25 +02:00
parent f14c915502
commit 76549581e6
4 changed files with 26 additions and 12 deletions

View File

@ -628,6 +628,10 @@ export default {
newAddress = Object.assign(newAddress, {
'addressReference': this.entity.selected.address.addressReference
});
} else {
newAddress = Object.assign(newAddress, {
'addressReference': null
});
}
if (this.validFrom) {

View File

@ -8,12 +8,15 @@ import L from 'leaflet';
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
import 'leaflet/dist/leaflet.css';
let map;
let marker;
export default {
name: 'AddressMap',
props: ['entity'],
data() {
return {
map: null,
marker: null
}
},
computed: {
center() {
return this.entity.selected.addressMap.center;
@ -21,30 +24,33 @@ export default {
},
methods:{
init() {
map = L.map('address_map').setView([46.67059, -1.42683], 12);
this.map = L.map('address_map').setView([46.67059, -1.42683], 12);
map.scrollWheelZoom.disable();
this.map.scrollWheelZoom.disable();
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
}).addTo(this.map);
const markerIcon = L.icon({
iconUrl: markerIconPng,
iconAnchor: [12, 41],
});
marker = L.marker([48.8589, 2.3469], {icon: markerIcon}).addTo(map);
this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon});
this.marker.addTo(this.map);
},
update() {
//console.log('update map with : ', this.address.addressMap.center)
marker.setLatLng(this.entity.addressMap.center);
map.setView(this.entity.addressMap.center, 15);
//console.log('update map with : ', this.entity.addressMap.center)
if (this.marker && this.entity.addressMap.center) {
this.marker.setLatLng(this.entity.addressMap.center);
this.map.setView(this.entity.addressMap.center, 15);
}
}
},
mounted(){
this.init()
this.init();
this.update();
}
}
</script>

View File

@ -106,6 +106,9 @@ export default {
this.$emit('getReferenceAddresses', this.value);
if (this.value.center) {
this.updateMapCenter(this.value.center);
if (this.value.center.coordinates) {
this.entity.selected.postcode.coordinates = this.value.center.coordinates;
}
}
}
},

View File

@ -71,6 +71,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
'id' => $address->getPostCode()->getId(),
'name' => $address->getPostCode()->getName(),
'code' => $address->getPostCode()->getCode(),
'center' => $address->getPostcode()->getCenter(),
],
'country' => [
'id' => $address->getPostCode()->getCountry()->getId(),