mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
address selection: fix leaflet icon url + others fix (WIP)
This commit is contained in:
@@ -6,9 +6,9 @@ import { getDataPromise } from './store'
|
||||
|
||||
import App from './App.vue';
|
||||
|
||||
getDataPromise.then(store => {
|
||||
|
||||
console.log('store address', store.state.referenceAddresses);
|
||||
|
||||
getDataPromise.then(store => {
|
||||
|
||||
const i18n = _createI18n(addressMessages);
|
||||
|
||||
|
@@ -1,38 +0,0 @@
|
||||
import L from 'leaflet';
|
||||
|
||||
export const initMap = () => {
|
||||
|
||||
|
||||
let map = L.map('address_map').setView([48.8589, 2.3469], 12);
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
|
||||
L.marker([48.8589, 2.3469]).addTo(map)
|
||||
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
|
||||
.openPopup();
|
||||
|
||||
console.log(map);
|
||||
return map;
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const updateMap = (state) => {
|
||||
|
||||
// console.log(state.map.center);
|
||||
|
||||
// let map = L.map('address_map').setView(state.map.center, state.map.zoom);
|
||||
|
||||
// L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
// attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
// }).addTo(map);
|
||||
|
||||
// L.marker(state.map.center).addTo(map)
|
||||
// .bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
|
||||
// .openPopup();
|
||||
|
||||
// console.log(map);
|
||||
};
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
import { getReferenceAddress } from '../api';
|
||||
import { app } from '../index';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
@@ -20,11 +21,11 @@ const getDataPromise = getReferenceAddress()
|
||||
{id: 2, name: 'Aisne', code: '85045', country: 'FR'},
|
||||
{id: 3, name: 'Saint-Gervais', code: '85230', country: 'FR'}
|
||||
], //TODO fetch postal codes from CHILL API
|
||||
selectedCountry: {id: 1, name: 'France', countryCode: 'FR'}, // TODO is it ok to specify a default value here?
|
||||
selectedCountry: {id: 1, name: 'France', countryCode: 'FR'},
|
||||
selectedCity: null,
|
||||
selectedAddress: null,
|
||||
addressMap: {
|
||||
center : [48.8589, 2.3469],
|
||||
center : [48.8589, 2.3469], // Note: LeafletJs demands [lat, lon] cfr https://macwright.com/lonlat/
|
||||
zoom: 12
|
||||
},
|
||||
form: {
|
||||
@@ -41,6 +42,7 @@ const getDataPromise = getReferenceAddress()
|
||||
state.cities :
|
||||
state.cities.filter(c => c.country == state.selectedCountry.countryCode),
|
||||
getReferenceAddresses: state => state.referenceAddresses, //TODO filter as a function of city
|
||||
getMapCenter: state => state.addressMap.center,
|
||||
},
|
||||
mutations: {
|
||||
setSelectedCountry(state, value) {
|
||||
@@ -50,10 +52,9 @@ const getDataPromise = getReferenceAddress()
|
||||
state.selectedCity = value;
|
||||
},
|
||||
setSelectedAddress(state, value) {
|
||||
console.log(value)
|
||||
state.selectedAddress = value;
|
||||
state.addressMap.center = value.point.coordinates; //TODO is it OK to put this here? //call setMapCenter
|
||||
updateMap(state); //TODO where to listen to map center change? -> action avec dispatch
|
||||
state.addressMap.center = value.point.coordinates.reverse();
|
||||
//app.$refs.addressMap.updateMap(); //TODO how to update the map view? -> action avec dispatch
|
||||
},
|
||||
setMapCenter(state, value) {
|
||||
state.addressMap.center = value;
|
||||
@@ -63,6 +64,9 @@ const getDataPromise = getReferenceAddress()
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
updateMapCenter({ commit }, payload) {
|
||||
commit('updateMapCenter', payload);
|
||||
},
|
||||
}
|
||||
});
|
||||
resolve(store);
|
||||
|
Reference in New Issue
Block a user