Is It possible to get the exact user location i.e; city, and state without using the clientcontext method and google api's
Solved! Go to Solution.
Views
Replies
Total Likes
You can use W3C Geolocation APIs to get the latitude and longitude and then call the Google Maps API to get the city, state information.
http://www.w3schools.com/html/html5_geolocation.asp
http://stackoverflow.com/questions/6797569/get-city-name-using-geolocation
Views
Replies
Total Likes
You can use W3C Geolocation APIs to get the latitude and longitude and then call the Google Maps API to get the city, state information.
http://www.w3schools.com/html/html5_geolocation.asp
http://stackoverflow.com/questions/6797569/get-city-name-using-geolocation
Views
Replies
Total Likes
Hi
Adding to Kunal's comment,
You can read more about it at http://viralpatel.net/blogs/html5-geolocation-api-tutorial-example/
//
This method is good because it's easy to implement and is fairly accurate at a country level but accuracy drops considerably for anything more specific.
// API key excluded for brevity, see full demo.var apiurl = 'http://api.ipinfodb.com/v3/ip-city';$.getJSON(apiurl+'/format=json&callback=?',function(data){$("h3#location").html(data.regionName + ", " + data.countryName);});
Although by no means perfect, this method is as accurate as it gets. User is prompted to share geolocation details which may reduce usage.
navigator.geolocation.getCurrentPosition(function(pos){$.getJSON(apiurl+'/format=json&callback=?',function(data){var regionName = data[...]AdministrativeAreaName;var countryName = data[...]CountryName;$("h3#location").html(regionName + ", " + countryName);});});
In there you'll see I used the Google Maps API v3 by way of YQL so that a JSON callback is possible.
I hope this will help you.
Thanks and Regards
KautuK Sahni
Views
Replies
Total Likes
Views
Likes
Replies