diff --git a/src/services/map-service.js b/src/services/map-service.js index 0bb14fa3a7276e2d9ce9a354d9eb4e0e3e584e2a..c64c318d9e024d9bb3900caff85d1ef8456df50c 100644 --- a/src/services/map-service.js +++ b/src/services/map-service.js @@ -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' })); diff --git a/src/store/modules/map.store.js b/src/store/modules/map.store.js index a8b3f37b29b4f49fef161c4d5f47d192182e7030..3ae7994329dc93751cd400d5c39892bf842b2850 100644 --- a/src/store/modules/map.store.js +++ b/src/store/modules/map.store.js @@ -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); diff --git a/src/views/Feature/FeatureDetail.vue b/src/views/Feature/FeatureDetail.vue index dc39b0e4733573a96363fa432c3dd587fb2ad6e7..6926b84925ecad4dde6bd8fe2422beddc5bafdf5 100644 --- a/src/views/Feature/FeatureDetail.vue +++ b/src/views/Feature/FeatureDetail.vue @@ -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, diff --git a/src/views/Feature/FeatureEdit.vue b/src/views/Feature/FeatureEdit.vue index ce39380330ef83d5ac10aa38060f513bc8308e56..68b7a5d39641400209748e13a8f2cc28b4f3cdf0 100644 --- a/src/views/Feature/FeatureEdit.vue +++ b/src/views/Feature/FeatureEdit.vue @@ -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; diff --git a/src/views/Project/FeaturesListAndMap.vue b/src/views/Project/FeaturesListAndMap.vue index f86c9244e9e77fd13ad692680ef7208400f8ab04..fde352a957e3980fea4e7b76329ca27f1d3fdd78 100644 --- a/src/views/Project/FeaturesListAndMap.vue +++ b/src/views/Project/FeaturesListAndMap.vue @@ -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 } });