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="mapbox_sat"/><br/>
            x:  <input name="x" value="2493"/><br/>
            y:  <input name="y" value="1479"/><br/>
            z:  <input name="z" value="13"/><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 s = "abc".charAt(Math.floor(Math.random()*3));
    var url = 'https://'+s+'.tiles.mapbox.com/v3/examples.map-b70jh5xu/'+(z-1)+'/'+x+'/'+y+'.png';
    return url;        
};