1
0
forked from MTSR/mapserver

coord compat

This commit is contained in:
Thomas Rudin 2019-11-30 17:21:30 +01:00
parent 89e6591f9a
commit a99e9d48aa

View File

@ -2,14 +2,31 @@
export function hashCompat(){ export function hashCompat(){
if (window.location.hash) { if (window.location.hash) {
let match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)$/m);
if (match) { const parts = window.location.hash.replace("#", "").split("/");
window.location.hash = `#!/map/0/${match[1]}/${match[2]}/${match[3]}`; if (parts.length == 0){
//invalid
return;
} }
match = window.location.hash.match(/^#\/(\d*)\/(\d*)\/(\d*)\/(\d*)$/m); if (parts[0] == "map"){
if (match) { //new link
window.location.hash = `#!/map/${match[1]}/${match[2]}/${match[3]}/${match[4]}`; return;
}
if (isNaN(+parts[0])){
//NaN
return;
}
if (parts.length == 3){
//#1799.5/399/10
window.location.hash = `#!/map/0/${parts[0]}/${parts[1]}/${parts[2]}`;
}
if (parts.length == 4) {
//#0/-1799.5/399/10
window.location.hash = `#!/map/${parts[0]}/${parts[3]}/${parts[1]}/${parts[2]}`;
} }
} }
} }