views:

117

answers:

3

I'm building a php based application for a client to enter in addresses for their customers' buildings. They'd like the ability to view the location on a map (either as individuals or grouped in a city search).

What I'm trying to accomplish is a lookup once the address is entered into a form that populates the database, so after they enter in the addresss, city, state, zip (these are all US locations) they could click a "get lat/long info" link/button that would check to make sure the data is complete, then would lookup the address and return the latitude/longitude into the appropriate form fields. Then the form could be submitted to store the info, and I could later just pull the lat/long when plotting on a map.

1) Does this make sense, or would I be better off just doing the lookup when it's time to plot it?

2) Does anyone have any pointers to solve this problem?

I've seen some of the Google/Yahoo API's but it looks like this is more based on the plotting a point part. I may be able to modify it to suit my needs, but I'm just trying to cut some research time posting here with the hopes one of you may have a more direct route.

I'll RTFM if I have to...

Thanks, D.

A: 

A quick Google search for PHP geocoding returned this: http://code.google.com/apis/maps/articles/phpsqlgeocode.html. You may have to tailor it a bit to your needs, but that should definitely get you going.

ABach
+2  A: 

What you're looking for is referred to as geocoding; check out Google's Geocoding web service:

Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map.

The Google Maps API Geocoding Service provides a direct way to access a geocoder via an HTTP request. Additionally, the service allows you to perform the converse operation (turning coordinates into addresses); this process is known as "reverse geocoding."

Your approach to the problem makes sense, although I'm not sure how much validation a geocoding result actually provides (unless you're showing your users the resulting plot on a map).

Dolph
Thanks for the help. In a past project when I ran a batch script some addresses weren't found and people would ask. I thought confirming as entered may help. Some addresses are like "corner of this and that" so this may force them to find a "real" building number. I appreciate the help.
Don
+1  A: 

I would like to suggest you get a service from ZIPCodeWorld.com . You just need to enter the ZIP Code from US, you are able to get the latitude and longitude information.

JaceyKala