mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
address: fix bug when editing address: update localisation and addressreferenceId + better update of the map in edition
This commit is contained in:
parent
f14c915502
commit
76549581e6
@ -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) {
|
||||
|
@ -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: '© <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>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user