Does mdg:geolocation work on desktop?


#1

Or is it mobile only?

I need the lat and long of the user when they hit my landing page.


#2

mdg:geolocation just leverages the Geolocation Web API that is already implemented in most modern browsers. So you don’t really need that package. For example, run the following in your Chrome console:

function success(position) {
  console.log('Latitude: ' + position.coords.latitude);
  console.log('Longitude: ' + position.coords.longitude);
}

function error() {
  console.log("Oh no - we can't find you!");
}

navigator.geolocation.getCurrentPosition(success, error);

#3

Hey, @hwillson, how can I determine city based on lat and long?


#4

You can use the reverse geocoding feature of Google’s Geocoding API to do this. Check out the reverse-geocoding npm package.