-1

i want to get the user location information like city, area etc using html5 geolocation,i tried the below article but with that im getting latitude and longitude, i want to get the city and area information, http://www.dotnetcurry.com/ShowArticle.aspx?ID=782

colors bright
  • 107
  • 1
  • 3
  • 18

1 Answers1

0

When you have the location of the user, you'll need to do a reverse geocoding to get information about the location such as city, etc.

Have a look at the reverse geocoding API for Google Maps.

navigator.geolocation.getCurrentPosition(function(pos){
    var latlng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
    geocoder.geocode({'latLng': latlng}, function(results, status) {
        console.log(results);
        // Analyze results and find the info you need.
    });
});

Check out How to reverse geocode without Google for information about geocoding without using Google Maps.

Community
  • 1
  • 1
Jørgen
  • 8,820
  • 9
  • 47
  • 67