# HG changeset patch # User Markus Kottlaender # Date 1550500734 -3600 # Node ID 92b21df288e22768ef5175fa3b657abac3397e74 # Parent 77adbdd24d52870b02ad21aa48c8e8f8905207d3 client: use user specific extent only on initial load The map initialization is executed each time you go from a non-map view (configuration etc.) back to the map. Thus we cannot move the map to the user specific extent everytime the map is initialized. The fix that this commit introduces is maybe a bit ugly but an ideal solution would require more work. The problem is that the map cannot be initialized with the users bounding box right away. There is already a default map extent, defined by center and zoom. This needs to be overwritten by the user specific extent. diff -r 77adbdd24d52 -r 92b21df288e2 client/src/components/Maplayer.vue --- a/client/src/components/Maplayer.vue Mon Feb 18 15:33:01 2019 +0100 +++ b/client/src/components/Maplayer.vue Mon Feb 18 15:38:54 2019 +0100 @@ -53,6 +53,7 @@ computed: { ...mapGetters("map", ["getLayerByName", "getVSourceByName"]), ...mapState("map", [ + "initialLoad", "extent", "layers", "openLayersMap", @@ -181,32 +182,35 @@ }); this.$store.dispatch("map/openLayersMap", map); - var currentUser = this.$store.state.user.user; - HTTP.get("/users/" + currentUser, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "text/xml; charset=UTF-8" - } - }) - .then(response => { - this.$store.commit("map/moveToBoundingBox", { - boundingBox: [ - response.data.extent.x1, - response.data.extent.y1, - response.data.extent.x2, - response.data.extent.y2 - ], - zoom: 17, - preventZoomOut: true + if (this.initialLoad) { + this.$store.commit("map/initialLoad", false); + var currentUser = this.$store.state.user.user; + HTTP.get("/users/" + currentUser, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } + }) + .then(response => { + this.$store.commit("map/moveToBoundingBox", { + boundingBox: [ + response.data.extent.x1, + response.data.extent.y1, + response.data.extent.x2, + response.data.extent.y2 + ], + zoom: 17, + preventZoomOut: true + }); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); }); - }) - .catch(error => { - const { status, data } = error.response; - displayError({ - title: this.$gettext("Backend Error"), - message: `${status}: ${data.message || data}` - }); - }); + } // TODO make display of layers more dynamic, e.g. from a list diff -r 77adbdd24d52 -r 92b21df288e2 client/src/store/map.js --- a/client/src/store/map.js Mon Feb 18 15:33:01 2019 +0100 +++ b/client/src/store/map.js Mon Feb 18 15:38:54 2019 +0100 @@ -63,6 +63,7 @@ const init = () => { return { openLayersMap: null, + initialLoad: true, extent: { lat: 6155376, lon: 1819178, @@ -475,6 +476,9 @@ } }, mutations: { + initialLoad: (state, initialLoad) => { + state.initialLoad = initialLoad; + }, extent: (state, extent) => { state.extent = extent; },