Skip to content

Commit

Permalink
positioning maps by parameters URL
Browse files Browse the repository at this point in the history
  • Loading branch information
vol4tim committed Feb 13, 2025
1 parent 3345de4 commit 62f2928
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,30 @@ export default {
// }
},
checkPosFromURI() {
if (this.$route.params.lat || this.$route.params.lng || this.$route.params.zoom) {
return true;
}
return false;
},
setPosFromURI() {
const lat = this.$route.params.lat || config.MAP.position.lat;
const lng = this.$route.params.lng || config.MAP.position.lng;
const zoom = this.$route.params.zoom || config.MAP.zoom;
this.store.setmapposition(lat, lng, zoom, true);
},
setgeo(forse = false) {
return new Promise((resolve, reject) => {
this.geoisloading = true;
if ("geolocation" in navigator) {
this.geoavailable = true;
if(localStorage.getItem("map-position") && !forse) {
if (this.checkPosFromURI() && !forse) {
this.setPosFromURI();
resolve("Geolocation is set from url params");
} else if (localStorage.getItem("map-position") && !forse) {
this.getlocalmappos();
resolve("Geolocation is set from local data");
} else {
Expand Down

0 comments on commit 62f2928

Please sign in to comment.