In my application i want to get the weather report I'm using http://www.google.com/ig/api?weather="" for that by providing a city. But for me only lat and longitude is available
How can I get the place name by lat and longitudes.
In my application i want to get the weather report I'm using http://www.google.com/ig/api?weather="" for that by providing a city. But for me only lat and longitude is available
How can I get the place name by lat and longitudes.
FYI, what you're doing is called reverse geocoding.
Most of the Geonames webservices are available in JSON, including findNearby.
Google also has a reverse geocoding webservice
What you're asking is not a small thing - a lat/lng database is almost certainly going to be presented in either XML or JSON, so it might be worth investing a little time and effort in this. Android must have xml/json wrappers?
You can use the Location API to get a Address Object and get the locality from there
There's no need to invoke the Geocoder
, in this weather API, which BTW is not public so you should use it with caution, city
, state
and country
are only informational fields, so you can use it like this (dummy constants):
private static final String URL = "http://www.google.com/ig/api?weather=%s,%s,%s,%d,%d";
//...
final String url = String.format(URL, "city", "state", "country",
p.getLatitudeE6(), p.getLongitudeE6());