persistent hash route

This commit is contained in:
BuckarooBanzay 2022-03-20 19:44:17 +01:00
parent c701170a07
commit 3735dbd242
2 changed files with 25 additions and 1 deletions

View File

@ -18,8 +18,32 @@ export default {
)
});
const updateLink = () => {
const center = map.getCenter();
const lon = Math.floor(center.lng);
const lat = Math.floor(center.lat);
console.log("Map::updateLink", map.getZoom(), lon, lat);
// change hash route
this.$router.push({
name: "map",
params: {
lat: lat,
lon: lon,
zoom: map.getZoom(),
layerId: this.layerId
}
});
};
// listen for route change
map.on('zoomend', updateLink);
map.on('moveend', updateLink);
// add attribution
map.attributionControl.addAttribution('<a href="https://github.com/minetest-mapserver/mapserver">Minetest Mapserver</a>');
// TODO: all layers
var tileLayer = new RealtimeTileLayer(ws, this.layerId, map);
tileLayer.addTo(map);

View File

@ -2,7 +2,7 @@ import MapPage from "./pages/MapPage.js";
export default [{
path: "/map/:layerId/:zoom/:lon/:lat", component: MapPage
path: "/map/:layerId/:zoom/:lon/:lat", name: "map", component: MapPage
},{
path: "/", redirect: "/map/0/13/0/0"
}];