Can Google Maps API Validate If an Address Is Valid?

Save

Google created the Google Maps API, or application programming interface, to allow you to create a program that can interact with Google Maps to retrieve information and present it to your program's end user. Although the Google Maps API does not have a specific method for validating addresses, Google's Geocoding API provides information that allows you to determine if Google has information about a specific address.

Geocoding

  • Google's Geocoding API accepts addresses in a human readable form and returns information about that address including its latitude and longitude. If you enter a valid address, Google will return an exact latitude and longitude location. If you enter an invalid address, Google will also return a location range in which the address would be contained if it existed. Google limits usage of its Geocoding API to 2,500 requests per day. The API can only be used if you display the results on a Google map.

HTTP Requests

Responses

  • Google will return a formatted XML or JSON file containing information about the address that you provided. The results array within the file will contain a listing of valid results for your search. In most cases, this result will only include a single result. Within the geometry array, you will find information about the returned location. The location_type field indicates what type of location information Google has for the address that you provided. If Google recognizes the address as a valid address it will return "ROOFTOP" as the location_type. If Google does not recognize the address it will also return a bounds field within the geometry field. Bounds contains latitude and longitude values that represent a bounding box that would contain the address if it existed. Google may also return a partial_match field if it could not identify the address that you provided as a valid address.

Reverse Geocoding

  • If Google cannot identify the address that you provided, you can use the information that Google provides to find the nearest valid address to the location where the invalid address would be located. The location field within the geometry field in the results contains Google's best guess about the location of the invalid address that you provided. If you pass this latitude and longitude into a geocoding request in place of an address, Google will return the closest actual address to that location or a range of addresses in that region. For example, Google returns 41.8925030, -87.62674989999999 as the closest latitude and longitude to the nonvalid address: 30 East Ohio, Chicago IL. If you request that latitude and longitude from Google as follows:

    http://maps.googleapis.com/maps/api/geocode/json?latlng=41.8925030,-87.62674989999999&sensor=false

    Then it returns the nearest actual address: 600 N Wabash Ave, Chicago IL.

References

Promoted By Zergnet

Comments

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!