Gmail/Contacts does a great job of parsing this address into specific address fields.
7 Prasad Road, Narimedu, Madurai, Tamil Nadu, India
is accurately parsed to be: Street: 7 Prasad Road Neighborhood: Narimedu City: Madurai State/Province: Tamil Nadu, Country: India
Is there anyway to use Google Maps Contacts API just to transform free text into address fields like this?
One more thing to note: This is for a non-profit. Not a commercial site.
I'm concerned about using Geocoding to approximate because we are working globally and Google Maps is not too accurate in finding the right location in some countries. I still don't want to lose information user has entered. Usually we need to be able to filter addresses by city and state so these need to parsed exactly. The rest of it should not be lost. With geocoding, I'm finding that it formats the address to remove the fields that it doesn't understand. In gmail contacts, it leaves that alone and parses what it is able to parse.
Thanks, Safris
UPDATE: Google maps api is able to pick up the neighborhood, city, state, country from what the user has typed. When I hit the api by doing this: http://maps.googleapis.com/maps/api/geocode/json?address=B19/F1%20Vigyanapuri,%20Vidyanagar,%20Hyd%20500044%20,India&sensor=false, it then returns back the following result:
{
"results" : [
{
"address_components" : [
{
"long_name" : "Vigyanpuri Colony Park",
"short_name" : "Vigyanpuri Colony Park",
"types" : [ "point_of_interest", "establishment" ]
},
{
"long_name" : "APHB Colony",
"short_name" : "APHB Colony",
"types" : [ "neighborhood", "political" ]
},
{
"long_name" : "Adikmet",
"short_name" : "Adikmet",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "Hyderabad",
"short_name" : "HYD",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Hyderabad",
"short_name" : "Hyderabad",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Andhra Pradesh",
"short_name" : "Andhra Pradesh",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
},
{
"long_name" : "500044",
"short_name" : "500044",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Vigyanpuri Colony Park, APHB Colony, Adikmet, Hyderabad, Andhra Pradesh 500044, India",
"geometry" : {
"location" : {
"lat" : 17.40368240,
"lng" : 78.51184130
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 17.41432930,
"lng" : 78.52784870000001
},
"southwest" : {
"lat" : 17.39303490,
"lng" : 78.49583389999999
}
}
},
"partial_match" : true,
"types" : [ "point_of_interest", "park", "establishment" ]
}
],
"status" : "OK"
}
But I'm just not sure how far to trust this - as far as I can tell, it seems accurate. I would like to take the address that user entered and parse it with google maps api and put it on a map approximately and have them correct me if I'm wrong. In Gmail/Contacts, I'm able to add address as a text field and it parses it by 'street address', whatever it couldn't parse, and then if it finds an accurate city, it puts it in, same with State/Province. I just wasn't sure how it is able to leave everything in street address, what it couldn't parse. Does Google's Contacts API allow us to use this without saving contacts to Google.
Thanks for looking into this! Safris