The term geocoding generally refers to translating a human-readable address into a location on the map. The process of doing the converse, translating a location on the map into a human-readable address, is known as reverse geocoding. You can read more about geocoding here.
The Geocoder in Google Maps API v3, supports reverse geocoding directly. While geocoding, we supply a textual address and that gets mapped as a location on the map. However, in reverse geocoding, instead of supplying the textual address, we will supply a comma- separated latitude- longitude pair and get a textual address as the result. You can have a look at the geocoding example here, before proceeding to the reverse geocoding example.
The reverse geocoder often returns more than one result. Geocoding "addresses" are not just postal addresses, but any way to geographically name a location. For example, when geocoding a point in the city of Agra, India, the geocoded point may be labelled as a street address, as the city (Agra), as its state (Uttar Pradesh) or as a country (India). All are addresses to the geocoder. The reverse geocoder returns all of these results. Addresses are returned in the order of best to least matches.
Before it gets too confusing, let us have a look at the following reverse geocoding example and based on the same we will discuss the addresses.
The main thing that needs concentration in the above code is "results[]". The Google Maps API v3 returns 7 values in the descending order of accuracy of the textual address. In the above code, I have used "results[0]" which will return the most accurate result of reverse geocoding; i.e. the most accurate textual, human-understandable address will be returned.
The output of the above code for results[0] is as seen below. Please see the details of the address in the info-window.
The Geocoder in Google Maps API v3, supports reverse geocoding directly. While geocoding, we supply a textual address and that gets mapped as a location on the map. However, in reverse geocoding, instead of supplying the textual address, we will supply a comma- separated latitude- longitude pair and get a textual address as the result. You can have a look at the geocoding example here, before proceeding to the reverse geocoding example.
The reverse geocoder often returns more than one result. Geocoding "addresses" are not just postal addresses, but any way to geographically name a location. For example, when geocoding a point in the city of Agra, India, the geocoded point may be labelled as a street address, as the city (Agra), as its state (Uttar Pradesh) or as a country (India). All are addresses to the geocoder. The reverse geocoder returns all of these results. Addresses are returned in the order of best to least matches.
Before it gets too confusing, let us have a look at the following reverse geocoding example and based on the same we will discuss the addresses.
The main thing that needs concentration in the above code is "results[]". The Google Maps API v3 returns 7 values in the descending order of accuracy of the textual address. In the above code, I have used "results[0]" which will return the most accurate result of reverse geocoding; i.e. the most accurate textual, human-understandable address will be returned.
The output of the above code for results[0] is as seen below. Please see the details of the address in the info-window.
For results[1] :
For results[2] :
For results[3] :
For results[4] :
For results[5] :
For results[6] :
As you can see that, the accuracy of the results[] geocoding keeps on decreasing. Now if you put results[7], then the output would be as seen in the image below. The geocoder finds no results to return.
I hope the concept of reverse geocoding is now clear along with the results that are returned by the geocoder. Hope the images speak my words.If you have any further doubts or queries regarding this post then please feel free to drop a comment here.
Till then...Happy mapping!
Comments
Post a Comment
Please leave your comments here...