Viewed   162 times

So I have latitude and longitude Like 44.4647452 and 7.3553838. I need to get address like: Milan, Italy, str. Kennedy 89.

How I can do it?

 Answers

5

Simply pass latitude, longitude and your Google API Key to the following query string, you will get a json array, fetch your city from there.

https://maps.googleapis.com/maps/api/geocode/json?latlng=44.4647452,7.3553838&key=YOUR_API_KEY

Note: Ensure that no space exists between the latitude and longitude values when passed in the latlng parameter.

Click here to get an API key

Tuesday, September 13, 2022
1

Currently Google Maps JavaScript API doesn't expose any boundaries of geographic features. There is very old feature request in the public issue tracker to add this functionality, however it looks like Google didn't set high priority on this:

https://issuetracker.google.com/issues/35816953

Feel free to star the public feature request to express your interest and subscribe to further updates from Google.

You can get polygons from other sources and add them to Google maps as additional layers.

The nice workaround to get polygons in GeoJSON format from OpenStreetMap is described in the following answer:

https://.com/a/40172098/5140781

So, if you download the GeoJSON you will be able to add it to map using the data layer and its loadGeoJson() method:

https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson

You can style colors of GeoJSON objects and create info windows. Just read the aforementioned documentation.

I hope this helps!

Thursday, November 24, 2022
1

This is likely a Chrome browser issue.

The corresponding bug in the public issue tracker is

https://issuetracker.google.com/issues/38211242

Feel free to star the bug to add your vote and subscribe to further updates.

UPDATE

As stated in Google issue tracker, the issue was fixed in Chrome 60. The corresponding bug was marked as Fixed on August 9, 2017.

Sunday, December 25, 2022
2

From a Geocoder object, you can call the getFromLocation(double, double, int) method. It will return a list of Address objects that have a method getLocality().

Geocoder gcd = new Geocoder(context, Locale.getDefault());
List<Address> addresses = gcd.getFromLocation(lat, lng, 1);
if (addresses.size() > 0) {
    System.out.println(addresses.get(0).getLocality());
}
else {
   // do your stuff
}
Thursday, December 22, 2022
 
5

Try

Geocoder gcd = new Geocoder(this, Locale.getDefault());
List<Address> addresses = null;
try {
    addresses = gcd.getFromLocation(lat, lng, 1);
} catch (IOException e) {
    e.printStackTrace();
}
if (addresses != null && addresses.size() > 0) {
    String locality = addresses.get(0).getLocality();
}
Friday, August 12, 2022
 
ycx
 
ycx
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :