From 5626c52537c63b502ed7b9d41f37576c498366d4 Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Thu, 6 Jun 2019 12:53:42 +0200 Subject: [PATCH 1/2] CacheStart map shows marker for startstation again --- .../frontend/src/pages/CacheStart.vue | 2 +- .../frontend/src/pages/StationView.vue | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue index 951b7af..973eed8 100644 --- a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue +++ b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue @@ -9,7 +9,7 @@ - + diff --git a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue index 487d6bd..951c055 100644 --- a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue +++ b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue @@ -57,7 +57,7 @@ Vue.use(VueLayers); stationen: [], }, station: {}, - markercolor: "red", + markercolor: "grey", cameraActive: false, result: null, zoom: 15, @@ -121,8 +121,15 @@ Vue.use(VueLayers); }, getMarkerURL(station) { - console.log(station); - return `./statics/map-marker_${this.markercolor}.svg` + return `./statics/map-marker_${this.setMarkercolor(station)}.svg` + }, + setMarkercolor(station){ + if(this.station === cache.stationen.find(station => station.id === Number(this.$route.params.id))) { + this.markercolor = "red"; + } else if (this.station) { + this.markercolor = "grey"; + } + return this.markercolor }, updateResult(event) { From 9967df050878f46f7f6d26e10168337838c7ea97 Mon Sep 17 00:00:00 2001 From: Katharina Will Date: Thu, 6 Jun 2019 14:58:33 +0200 Subject: [PATCH 2/2] StaionView shows active and already visited stations in correct colored markers --- .../frontend/src/pages/CacheStart.vue | 1 + .../frontend/src/pages/StationView.vue | 57 +++++++++++-------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue index 973eed8..0803193 100644 --- a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue +++ b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/CacheStart.vue @@ -87,6 +87,7 @@ Vue.use(VueLayers); this.stationID = cache.stationen[0]; this.lon = this.stationID.longitude; this.lat = this.stationID.lattitude; + this.center = [this.lon, this.lat] }) }, checkStation() { diff --git a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue index 951c055..20c7c2c 100644 --- a/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue +++ b/labswp_2019_sose_geocaching_frontend/frontend/src/pages/StationView.vue @@ -4,12 +4,21 @@ data-projection="EPSG:4326" style="height: 200px" v-if="!cameraActive"> - + + + + @@ -64,6 +73,7 @@ Vue.use(VueLayers); center: [ 9.208858198755664, 49.14785422283188], rotation: 0, geolocPosition: undefined, + filteredStations: [], } }, beforeRouteUpdate(to, from, next) { @@ -105,31 +115,28 @@ Vue.use(VueLayers); }, methods: { fetchData() { - this.$axios.get('/api/allCaches') - .then((response) => { - console.log("/api/allCaches"); - console.log(response.data); - const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache)); - this.cache = cache; - this.station = cache.stationen.find(station => station.id === Number(this.$route.params.id)); - this.cacheName = cache.name; - this.cacheID = this.$route.params.cache; - console.log(JSON.stringify(this.cache)); - console.log(JSON.stringify(this.station)); - console.log(this.cache); + if (localStorage.getItem('userToken')) { + let params = {cacheID: this.$route.params.cache}; + params.token = JSON.parse(localStorage.getItem('userToken')).token; + this.$axios.get('/api/getCurrentStation',{params}) + .then((response) => { + console.log("/api/getCurrentStation"); + console.log(response.data); + const cache = response.data.cache; + this.cache = cache; + this.station = response.data.aktuelleStation; + this.cacheName = cache.name; + this.cacheID = this.$route.params.cache; + console.log(JSON.stringify(this.cache)); + console.log(JSON.stringify(this.station)); + console.log(this.cache); + let stationIndex = this.cache.stationen.findIndex(s => s.id === this.station.id); + for( let i=0; i< stationIndex; i++){ + this.filteredStations.push(this.cache.stationen[i]) + } + this.center = [this.station.longitude, this.station.lattitude] }) - }, - - getMarkerURL(station) { - return `./statics/map-marker_${this.setMarkercolor(station)}.svg` - }, - setMarkercolor(station){ - if(this.station === cache.stationen.find(station => station.id === Number(this.$route.params.id))) { - this.markercolor = "red"; - } else if (this.station) { - this.markercolor = "grey"; } - return this.markercolor }, updateResult(event) {