viewof position = {
const form = html`<form><button name=button>Where am I?`;
form.button.onclick = event => {
event.preventDefault();
navigator.geolocation.getCurrentPosition(
position => {
form.value = position;
form.dispatchEvent(new CustomEvent("input"));
},
error => {
form.value = Promise.reject(error);
form.dispatchEvent(new CustomEvent("input"));
},
{
timeout: 5000,
maximumAge: Infinity
}
);
};
return form;
}