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.
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.
processing...Welcome to Webmonkey
- edit articles
- add to the code library
- design and write a tutorial
- comment on any Webmonkey article
Sign In Information Sent
Get Started With the Yahoo HTTP Geocoder API
/skill level/
/viewed/
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:
/related_articles/
Special Offer For Webmonkey Users
WIRED magazine:
The first word on how technology is changing our world.
