Home

Geolocation API

Static map API

Geolocation API

Location

watch position

const o={lat:51.16095,lng:4.96166,zoom:15,getCoordinates:()=>JSON.stringify(o),getMapUrl(){return`https://static-maps.yandex.ru/1.x/?lang=en_US&l=map&z=${this.zoom}&size=650,350&pt=${`${this.lng},${this.lat}`},pm2rdm1`}},t=document.getElementById("zoom"),e=document.querySelector(".card"),n=e.querySelector("p"),i=e.querySelector("img"),r={enableHighAccuracy:!0,timeout:3e3};function a(){n.innerHTML="My location "+o.getCoordinates(),i.src=o.getMapUrl()}navigator.geolocation?navigator.geolocation.watchPosition((function(t){console.log("new position",t),o.lat=t.coords.latitude,o.lng=t.coords.longitude,a()}),(function(){n.innerHTML="Unable to retrieve your location"}),r):n.innerHTML="Geolocation is not supported by this browser.",t.addEventListener("change",()=>{o.zoom=t.value,a()});
//# sourceMappingURL=geolocation.js.map