Skip to content

Commit

Permalink
Merge pull request #144 from positivecrash/master
Browse files Browse the repository at this point in the history
fix map issue
  • Loading branch information
positivecrash authored Jul 16, 2024
2 parents 82458fc + 708fe76 commit d79d1ac
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/components/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default {
},
relocatemap(lat, lng, zoom, type) {
console.log('relocatemap', lat, lng, zoom, type)
const options = {
name: "main",
params: {
Expand Down Expand Up @@ -110,7 +111,7 @@ export default {
},
setgeo(force = false) {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
const latinurl = this.$router?.currentRoute.value?.params?.lat;
const lnginurl = this.$router?.currentRoute.value?.params?.lng;
const zoominurl = this.$router?.currentRoute.value?.params?.zoom;
Expand All @@ -123,38 +124,37 @@ export default {
/* setting for the app globally user's geo position and zoom 20 for better view */
this.userposition = [position.coords.latitude, position.coords.longitude];
this.store.setmapposition(this.userposition[0], this.userposition[1], 20);
resolve();
},
(e) => {
/* Если не удалось получить позицию юзера, то проверяем локальное хранилище */
console.warn(`ERROR(${e.code}): ${e.message}`);
console.error(`geolocation error(${e.code}): ${e.message}`);
this.getlocalmappos();
reject();
},
{
enableHighAccuracy: true,
enableHighAccuracy: false,
timeout: 20000,
maximumAge: 0
maximumAge: 1000
}
);
} else {
/* Если нет возможности "geolocation", то проверяем локальное хранилище */
this.getlocalmappos();
resolve();
}
} else {
this.store.setmapposition(latinurl, lnginurl, zoominurl || config.MAP.position.zoom);
resolve();
}
resolve();
});
},
resetgeo() {
const waitcoords = this.setgeo(true);
waitcoords.then(() => {
this.setgeo(true).then(() => {
this.relocatemap(this.lat, this.lng, this.zoom, "reload");
});
}).catch(e => {
console.log('resetgeo error', e)
})
},
setgeopermission(permission) {
Expand Down Expand Up @@ -199,9 +199,8 @@ export default {
/* + Operate with a map */
/* retrieve coordinates */
const waitcoords = this.setgeo();
waitcoords.then(async () => {
this.setgeo()
.then(async () => {
const map = init([this.lat, this.lng], this.zoom, this.theme);
this.relocatemap(this.lat, this.lng, this.zoom, "reload");
Expand Down Expand Up @@ -236,7 +235,6 @@ export default {
e.target.getZoom()
);
}, 50)
});
initMarkers(map, this.measuretype, (data) => {
Expand All @@ -247,6 +245,9 @@ export default {
await initWind();
}
});
// .catch(() => {
// console.error('map drawing error');
// });
/* - Operate with a map */
/* get bookmarks and listenning for broadcast from DB */
Expand Down

0 comments on commit d79d1ac

Please sign in to comment.