parent
54677b52b7
commit
752bc7469b
1 changed files with 44 additions and 6 deletions
|
@ -216,6 +216,13 @@ export default {
|
||||||
|
|
||||||
return this.map as Map
|
return this.map as Map
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pointsById(): Record<string, GPSPoint> {
|
||||||
|
return this.gpsPoints.reduce((acc: Record<string, GPSPoint>, point: GPSPoint) => {
|
||||||
|
acc[point.id] = point
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -415,6 +422,7 @@ export default {
|
||||||
...this.locationQuery,
|
...this.locationQuery,
|
||||||
...this.showMetrics.toQuery(),
|
...this.showMetrics.toQuery(),
|
||||||
resolutionMeters: this.resolutionMeters,
|
resolutionMeters: this.resolutionMeters,
|
||||||
|
selectedId: urlQuery.selectedId,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -519,6 +527,7 @@ export default {
|
||||||
...newQuery,
|
...newQuery,
|
||||||
...this.showMetrics.toQuery(),
|
...this.showMetrics.toQuery(),
|
||||||
resolutionMeters: this.resolutionMeters,
|
resolutionMeters: this.resolutionMeters,
|
||||||
|
selectedId: this.selectedPoint?.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -549,6 +558,24 @@ export default {
|
||||||
this.refreshMap()
|
this.refreshMap()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initSelectedPoint() {
|
||||||
|
const query = this.parseQuery(window.location.href)
|
||||||
|
if (query.selectedId) {
|
||||||
|
const point = this.pointsById[query.selectedId]
|
||||||
|
if (point) {
|
||||||
|
this.selectPoint(point)
|
||||||
|
// @ts-ignore
|
||||||
|
this.$refs.popup.setPosition([point.longitude, point.latitude])
|
||||||
|
this.map?.getView().setCenter([point.longitude, point.latitude])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setQuery({
|
||||||
|
...query,
|
||||||
|
selectedId: this.selectedPoint?.id,
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -567,21 +594,29 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
resolutionMeters() {
|
resolutionMeters() {
|
||||||
|
const urlQuery = this.parseQuery(window.location.href)
|
||||||
this.setQuery({
|
this.setQuery({
|
||||||
...this.locationQuery,
|
...urlQuery,
|
||||||
...this.showMetrics.toQuery(),
|
|
||||||
resolutionMeters: this.resolutionMeters,
|
resolutionMeters: this.resolutionMeters,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.refreshMap()
|
this.refreshMap()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectedPoint() {
|
||||||
|
const urlQuery = this.parseQuery(window.location.href)
|
||||||
|
this.setQuery({
|
||||||
|
...urlQuery,
|
||||||
|
selectedId: this.selectedPoint?.id,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
showMetrics: {
|
showMetrics: {
|
||||||
handler() {
|
handler() {
|
||||||
|
const urlQuery = this.parseQuery(window.location.href)
|
||||||
this.setQuery({
|
this.setQuery({
|
||||||
...this.locationQuery,
|
...urlQuery,
|
||||||
...this.showMetrics.toQuery(),
|
...this.showMetrics.toQuery(),
|
||||||
resolutionMeters: this.resolutionMeters,
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
|
@ -590,13 +625,16 @@ export default {
|
||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.initQuery();
|
this.initQuery();
|
||||||
[this.gpsPoints, this.devices] = await Promise.all([
|
[this.gpsPoints, this.devices, this.countries] = await Promise.all([
|
||||||
this.fetch(),
|
this.fetch(),
|
||||||
this.getMyDevices(),
|
this.getMyDevices(),
|
||||||
|
this.getCountries(),
|
||||||
])
|
])
|
||||||
|
|
||||||
this.map = this.createMap()
|
this.map = this.createMap()
|
||||||
this.countries = await this.getCountries()
|
setTimeout(() => {
|
||||||
|
this.initSelectedPoint()
|
||||||
|
}, 1000)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue