Geolocation API JavaScript logic