maps

Jan 08 11:19

Embedding Yahoo Maps

While working on a site (powered by drupal, of course), I came to the location page, wherein I needed to place a map. I knew I could cut-n-paste a static image of the location, then link it to either Google or Yahoo maps for further activity, but I wanted something a little more interactive. So I checked out the Yahoo! Developer Network for their maps API, and sure enough, they had lots of cool tools for embedding their map software in your code. I've been drinking the Yahoo! kool-aid ever since I signed up for free email with them 8 years ago.

I wanted an interactive map, but I didn't want to have to code up a separate flash or AJAX application and upload it. That's when I found their JS-Flash API. You call a little bit of javascript in your page, and it loads a flash application hosted by Yahoo! into a div on your page. It was perfect. All you have to do is sign up for a free Yahoo Developer Application ID.

After playing around a little bit, I was able to embed all of the code that I needed right into a drupal page, no external module coding needed. So I could put a highly interactive and customized map into the page just by putting code into drupal's web-based page creation form. No FTP, no SSH, no installing and configuring modules, just cut-n-paste into a form.

Here's the code I came up with. The important thing is that you set your input format as "PHP" because we need to use a function to put a bit of javascript in the <head> section of the page. Also, make sure you replace the appid portion with your personal AppID.

And here's what it looks like:

I thought I should wrap some of this up into a module, but when I looked, someone had already done it. I'll have to check it out.