Photo from Chile

Using ColdFusion to Create a Twitter/Google Maps Mashup

Update: Oops, I got it all wrong the first time. Check out the next article instead.

I thought it would be interesting to see a map of where all of my Twitter friends and followers are, and knowing that both Twitter and Google Maps provide APIs I figured I could throw something together pretty easily. I was not mistaken.

I made use of a number of Open Source libraries including Pedro Claudio's ColdFusion Twitter Lib, Ray Camden's Google Geocode, and the Google Maps API Utility Library. Using those libraries and a bit of ColdFusion and JavaScript code I was able to create a page that will show you where in the world all of your friends and followers are.

I use Twitter's API to get a list of your friends or followers, and then use Google's Geocode API to find the coordinates of their location (from their Twitter profile). I then create a Google Map via the JavaScript API, center the map at your location, and use the MarkerClusterer feature of the Google Maps API Utility Library to add a marker for each person (friend or follower) whose location could be determined. This allows the markers to appear as a cluster when zoomed out. As you zoom in you'll see each individual marker, at which point you can hover over it to see the person's screen name. All in all I think it's pretty cool, particularly when I consider that it only took me a couple of hours to throw the whole thing together, never having dealt with Twitter, Google Geocode or Google Maps before. It's a real testament to open source software.

The page I created is available as a demo, but you may not want to try it out from my server. The problem with this approach is that you must authenticate with Twitter in order to get the list of friends or followers, which means that you have to submit your screen name and password via the form which is not secured. If you want to see how it works you can just enter my screen name and leave the password blank. Or, if you're feeling risky, use your own screen name and password and see where your friends really are.

The code that I wrote to accomplish this feat is attached to this blog post. It was a very quick and dirty job, just trying to see if I could get it to work, so take it with a grain of salt. Note also that some of the code is borrowed from the sample that ships with Ray's Google Geocode project. Thanks Ray!

That was a lot of fun thanks for the interesting ideas and code
# Posted By Chris | 5/7/09 7:28 PM
I will post later, very cool
# Posted By Pedro Claudio | 5/7/09 7:59 PM
Hi Pedro. You'll see from my follow-up post that I had to make a small change to the library to allow me to get friends without authentication. You can download the new version attached to that post. Feel free to contact me to discuss the change if you wish.
# Posted By Bob Silverberg | 5/7/09 11:31 PM
Accepted the 5 lines that were changed, feel liberates to contact me or use my blog ( to suggest new alterations, or to indicate applications as this

+++ trunk/Twitter.cfc Thu May 7 21:00:39 2009
@@ -42,7 +42,9 @@
- <cfset userid = />
+ <cfif StructKeyExists(temp,"user")>
+ <cfset userid = />
+ </cfif>

@@ -97,7 +99,7 @@
- <cfset values = ListAppend(values,'#key#=#arguments.options[key]#','&') />
+ <cfset values = ListAppend(values,'#lcase(key)#=#arguments.options[key]#','&') />

@@ -405,7 +407,19 @@
- <cfreturn execute(uri, true) />
+ <cfreturn execute(uri, false) />
# Posted By Pedro Claudio | 5/8/09 12:31 AM