Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Sign in with OpenID
Sign In
Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

Get Started With the Yahoo HTTP Geocoder API

/skill level/
/viewed/
0 Times

Since the major search engines have opened up their mapping tools to programmers, geocoding has become an essential step in the process of building many a mashup.

Geocoding is the process of converting human-readable place data -- a city name, ZIP code, or address -- to latitude and longitude points that can be easily plotted on a map.

Yahoo's HTTP Geocoder API is easy to use, and its output is easy to incorporate into your applications. This article will describe its features and show some examples of how to access the results.


Contents

What You'll Need

  • Basic knowledge of XML
  • A Yahoo account
  • A Yahoo Application ID. Yahoo will ask for some information from you, but the good news is you get an ID right away.
  • To incorporate results with an application, you'll need some programming skills. I'll be showing code examples in PHP.


How to Proceed

Step 1: Start a Search

Yahoo provides several options to search for a location, such as specifying an address and city separately.

For example, here's the address for Wired.com, the home of Webmonkey:

520 3rd Street San Francisco, CA

Breaking this into pieces for the geocoder, we get:

street: 520 3rd Street city: San Francisco state: CA

The HTTP geocoder uses a simple URL. All we have to do is pass these pieces to the geocoder with the correct parameter. Here's the URL we can use for the Webmonkey address (remember to include your Application ID):

http://local.yahooapis.com/MapsService/V1/geocode?appid=appidhere&street=520+3rd+Street&city=San+Francisco&state=CA

Tip: Sometimes we may be geocoding an address that comes from a user. In that case, we don't always know where the street name ends and the city name begins. The Yahoo API provides a useful option of passing along everything as one parameter and letting the geocoder figure out which part is which. We'll do that here, using the location parameter:

http://local.yahooapis.com/MapsService/V1/geocode?appid=appidhere&location=520+3rd+Street+San+Francisco+CA

Both of these URLs return the exact same results. That geocoder is smart!


Step 2: View the Results

When we searched for the Webmonkey offices, we received a whole bunch of XML that looks like this:






Edit this article
Reddit Digg
 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year