Skip to content
Snippets Groups Projects
Commit 44bd2721 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

initiate maps with maxZoom from project config

parent 3f4fcd4e
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,7 @@ const mapService = {
lng,
mapDefaultViewCenter,
mapDefaultViewZoom,
maxZoom,
zoom,
zoomControl = true,
interactions = { doubleClickZoom: false, mouseWheelZoom: false, dragPan: true },
......@@ -60,7 +61,7 @@ const mapService = {
el.innerHTML = '';
}
this.map = new Map({
const mapOptions = {
layers: [],
target: el,
controls: [
......@@ -70,14 +71,17 @@ const mapService = {
})],
interactions: defaults(interactions),
view: new View({
center: transform([
!lng ? mapDefaultViewCenter[1] : lng,
!lat ? mapDefaultViewCenter[0] : lat,
center: transform([ //* since 0 is considered false, check for number instead of just defined (though boolean will pass through)
Number(lng) ? lng : mapDefaultViewCenter[1],
Number(lat) ? lat : mapDefaultViewCenter[0],
], 'EPSG:4326', 'EPSG:3857'),
zoom: !zoom ? mapDefaultViewZoom : zoom
zoom: Number(mapDefaultViewZoom) ? mapDefaultViewZoom : zoom,
maxZoom
}),
});
};
this.map = new Map(mapOptions);
if (zoomControl) {
this.map.addControl(new Zoom({ zoomInTipLabel: 'Zoomer', zoomOutTipLabel: 'Dézoomer' }));
......
......@@ -104,12 +104,13 @@ const map = {
});
},
INITIATE_MAP({ commit }, el) { //todo: since this function is not anymore called in different components, it would better to move it in project_details.vue
INITIATE_MAP({ commit, rootState }, el) { //todo: since this function is not anymore called in different components, it would better to move it in project_details.vue
const mapDefaultViewCenter = [46, 2]; // defaultMapView.center;
const mapDefaultViewZoom = 5; // defaultMapView.zoom;
mapService.createMap(el, {
mapDefaultViewCenter: mapDefaultViewCenter,
mapDefaultViewZoom: mapDefaultViewZoom,
maxZoom: rootState.projects.project.map_max_zoom_level,
});
const map = { ...mapService.getMap() };
commit('SET_MAP', map);
......
......@@ -354,6 +354,7 @@ export default {
this.map = mapService.createMap(this.$refs.map, {
mapDefaultViewCenter,
mapDefaultViewZoom,
maxZoom: this.project.map_max_zoom_level,
interactions : {
doubleClickZoom :false,
mouseWheelZoom: false,
......
......@@ -860,6 +860,7 @@ export default {
this.map = mapService.createMap(this.$refs.map, {
mapDefaultViewCenter,
mapDefaultViewZoom,
maxZoom: this.project.map_max_zoom_level,
interactions : { doubleClickZoom :false, mouseWheelZoom:true, dragPan:true }
});
const currentFeatureId = this.$route.params.slug_signal;
......
......@@ -303,6 +303,7 @@ export default {
lng: this.lng,
mapDefaultViewCenter,
mapDefaultViewZoom,
maxZoom: this.project.map_max_zoom_level,
interactions : { doubleClickZoom :false,mouseWheelZoom:true,dragPan:true }
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment