I am getting baffled with a problem that is, I can get the location of a user from Facebook and all I need is to get the latitude and longitude of that location, but I still couldn't find a solution.
It will help if I can get that latitude and longitude using an HTML5 geolocation or any Google API. What is the solution?
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(successFunction, errorFunction); } else { alert('It seems like Geolocation, which is required for this page, is not enabled in your browser. Please use a browser which supports it.'); }
If the browser supports geolocation and if getCurrentPosition
runs successfully, then a success function is called. And then in the function successFunction
have
function successFunction(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
console.log('Your latitude is :'+lat+' and longitude is '+long);
}
Read more on the Geolocation API here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With