天天看點

js - 通過浏覽器擷取目前坐标

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition((position) => {
            x = position.coords.longitude;
            y = position.coords.latitude;
        });
    }
    else { x.innerHTML = "Geolocation is not supported by this browser."; }
}
           

繼續閱讀