If you want to continually monitor the user's location, use the Geolocation API method, watchPosition()
. It works in the same way, except it will fire multiple times as the location of the user changes, or gets more accurate.
$("#storeLocation").click(() => {
const posOpts = { enableHighAccuracy: true, timeout: Infinity, maximumAge: 0 };
navigator.geolocation.watchPosition((e) => {
const position = a = e.coords.latitude + "," + e.coords.longitude;
// Store position here
}, posOpts);
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…