position error
My starting point.
by jib1
HTML
<div id="div" style="white-space: pre;"></div>
JavaScript
var console = { log: msg => div.innerHTML += msg + "<br>" };
var wait = ms => new Promise(resolve => setTimeout(resolve, ms));
function getCurrentLocation(options) {
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(resolve, ({code, message}) =>
reject(Object.assign(new Error(message), {name: "PositionError", code})),
options);
});
};
async function inout() {
try {
console.log(await this.getCurrentLocation({
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
}));
} catch (e) {
if (e.name == 'PositionError') {
console.log(e.message + ". code = " + e.code);
}
}
}
inout().catch(e => console.log(e));