Saturday, February 14, 2009

Finding Love Somewhere on Google Earth

For those of you still trying to find love, or who want to get a date for next year, I put together this sample app. Oh, BTW, careful, some of the images might not be safe for work. Sometimes people put risque things in their profiles.

I queried personal ads in Google Base using the Base API. Several different personals sites push their ads into Base to make them more discoverable. Base allows for location based queries, including a bounding box query that looks like this:[item type:personals][location(location): @+34-086..@+37-092]&content=geocodes

That query returns an Atom feed of personal ads within the bounding box. Don't worry, they don't put addresses in the ads, only City, State/Province, and Postal Code. And Base allows you to directly geocode within the query, returning additional g:latitude and g:longitude elements, to save you the hassle.

KML provides a convenient View Based Refresh. Simply put a viewRefreshMode of in a Link element, and Earth and Maps will send query parameters defining the bounding box of what is visible to a server. So, I put a simply python script up on an App Engine application, let it parse the bounding box parameters, and generate the queries, returning new KML every time the view pauses for more than a few seconds. Then I created a simple Earth API page, nothing fancy since it was getting late and I was tired, and loaded up the KML.

I could have used one of the Google Data Client Libraries, OK really only the Python one because I was using App Engine. But frankly, it was such a simple query, and I really love raw XML, I decided to stay with direct querying and DOM parsing.

If you want more info on View Based Refresh, look at the KML reference for viewFormat.

No comments: