JSFiddle - React, Tailwind, and code Playground

by Barbos

HTML

<img id="im"  width="256" height="256"/>
<div id="sp"></div>
<form>
            map:<input name="map" value="Navitel"/><br/>
            x:  <input name="x" value="38324"/><br/>
            y:  <input name="y" value="22097"/><br/>
            z:  <input name="z" value="17"/><br/>
            <input type="button" value="test" onClick="        
var url =computeUrl(form.map.value,form.x.value,form.y.value,form.z.value);
document.getElementById('im').src=url;
document.getElementById('sp').innerHTML=url;
return false;
"/>            
</form>

JavaScript

function computeUrl(mapName,x,y,z) {
    var y = (1<<(z-1))-(Number(y)+1)+'';
    var z = z-1+'';
    var s = '0' + Math.floor(Math.random()*3+1);
    while (x.length < 8) {x='0'+x};
    while (y.length < 8) {y='0'+y};
    while (z.length < 2) {z='0'+z};
    var url = 'http://m'+s+'.navitel.su/navitms.fcgi?t='+x+','+y+','+z;
    return url;        
};