zip code to latitude and longitude

Can you show me where I can get a code to convert from zip code or address to get

latitude/longitude is all I need to know. I know there is google xml that I can use. but need some helps to get latitude/longitude.

Who is Participating?
GaryConnect With a Mentor Commented:
Use the Google Map api
,success:function(data) {


Open in new window

Just pass in your zip code or address to the address part in the url

Working example

Sometimes you get two lots of coordinates.
solution1368Author Commented:
can you show me in c# eventually, i would like to create as a wcf service.
I don't know, you asked this in JavaScript.
If you want a .net version you should probably post a separate question in that topic area.
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I don't believe you will find this in any web scripting code.  The lat/lon for a polygon is based on the population centroid.   You would get this from the census.  However, it looks like due to the govt shutdown, it is not available.

There are plenty of sources to purchase data from if you are interested.
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
With GIS mapping in the U.S. polygons are made from things like postal carrier routes, zip codes, block groups, counties, states, congressional districts and countries.

Postal carrier routes are a subset of zip codes and determined by the postal service.  Block Groups are a subset of Counties and are determined by the census.     Counties are typically larger areas then Zips(Postal Code) and Zips will typically not match up with counties.  Just as postal carrier routes will not match up with block groups. Actually postal carrier routes can be disjointed and are based on the traffic patterns of the carrier.

The Centroid of the polygon refers to the the population center.  Let's say you live in zip code 12345 and the zip code is a square with 10,000 homes. In the north east corner of the zip there is a lake.  Because of the lake, there is heavy population.  The west side of the zip is made up of multiple large parks and nature reserves with few residents.  

Because the population is heavier in the north east, you would see the lat/lon point for that zip polygon placed closer towards the north east.    A good way to think of this is a fulcrum.  If you are on a teeter toter with 3 people on one side and one on the other, the point where the teeter toter needs to be attached has to be closer to the 3 people in order for it to balance.

That "balance" point is the centroid or population centroid.  I think this point is determined by the U.S. Census.  When you see points on a map based on a zip or state, that is typically the population centroid.
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Good solution.  You don't have to download your own data that way.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.