Question

I need to get the address by latitude and longitude from server side. I execute below web service and

seem there are multiple values for formatted address and address components for a given latitude.

http://maps.googleapis.com/maps/api/geocode/json?latlng=37.42426708029149,-122.0840722197085&sensor=true

How do I retrieve address for the given latitude and longitude from server side ?

How to get the absolute address ?

API says to use "ROOFTOP" indicates that the returned result is a precise geocode for which we have location information accurate down to street address precision. Any hint

Was it helpful?

Solution

@Kasun : Yes, You are right. As per the tutorial, Optional parameters are like result_type and location_type used to restrict the no of results. If we used the both parameter, we will get both type of the result. So analyse the requirement, before you going to use these parameters.

result_type : It is used to restrict the result set based on the address type. Can use One or more address types at a single request by using a pipe (|). Those types are following.

 1. country,
 2. street_address, 
 3. postal_code

location_type : It is used to restrict results based on the location type. Those types are following.

 1. ROOTTOP
 2. RANGE_INTERPOLATED
 3. GEOMETRIC_CENTER
 4. APPROXIMATE

NOTE : For your case ROOTTOP is enough. And also add street_address in result_type. keep it in mind - Use API key or Client ID to get the benefit of location_type.

How do I retrieve address ?

  1. JSON request to the Google Service by the following.

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false&key=API_KEY

Just append a lattitude and longtitude in the above format. Thatz all. You can give a one address at one time. Cant give bulk reverse geocoding(have to achieve it by loop).

OTHER TIPS

Just append a latitude and longitude in the above format. That is all.

You can give a one address at one time. Cant give bulk reverse geocoding(have to achieve it by loop).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top