Craigslist and Google Maps Mashup Thingy: Day 7 – Asynchronous JavaScript and XML!
I haven’t really been working on the Google Maps and Craigslist mashup very much recently. I blame it on a combination of going to Denver for a wedding, having a huge anime and manga backlog, getting Command and Conquer: Kane Edition, and general laziness. I think that’s a pretty good reason.
Anyway, today I sorta got back into it. As the mashup worked on day 6, the Google map would preload all the stuff within the tabs for the markers. This meant it would poll Craigslist like a billion times in one second to get all of the images preloaded. Guess what? Craigslist doesn’t like that. They put a ban on me (and anyone else who would use the badly implemented map) after loading one page. Luckily it was only a temporary ban.
My solution was to use AJAX to load the tabbed info windows for the markers on demand. So no pictures or anything get loaded until you request them. It’s much nicer to Craigslist, though I don’t know if it’s friendlier to my server, since there’ll be more requests. That’s okay, though.
It was kind of a pain to learn how to grab the xml files and parse them, but I finally got it working. Now all I have to do is generate the xml files for each listing (shouldn’t be hard at all). I’ve already got experience generating xml from the RSS feeds that I make for Notecentric and Anime Nano.
Plus, I get some street cred (maybe) for including AJAX in the site! It’s a requirement of Web 2.0, so I figure I should fulfill it.