Getting user location

Getting user’s geolocation

https://developer.mozilla.org/en-US/docs/WebAPI/Using_geolocation

1navigator.geolocation.getCurrentPosition(function(location) {
2  console.log(location.coords.latitude, location.coords.longitude);
3});

Browser will ask for user’s permisson before fetching the location. The following is the desktop Safari prompting for the geolocation feature permission.

Safari location permission

What’s next? We’re going to take a look at “Fetch weather from location”.

overlaied image when clicked on thumbnail

Makzan | Mobile web app dev with phonegap | Table of Content