Sunday, January 20, 2008

Hacking google street view

Lately I've found a real interest in hacking around web 2.0 APIs. What i really love about this new web and all it's REST interfaces is that all the data is there, and the ability to do whatever you want to it is there also. At most it's fiddling with a few URLs, maybe chaining a few together. You can make your own APIs into any service you want.

Todays I wanted to play around with the Google Street View. It seems really interesting, but google doesn't offer a public API. I wanted a way to type in an address and find the Street View pictures around that address. Eventually i might make a wrapper api and probably a rails plugin, but for now i was just interested in seeing how it worked. This is what i ended up with

http://tasks.turntheradiooff.com/street/view


First things first, view the source and see how it get's the information. Unfortunately, Google presents the street view in a flash application. This usually makes my job harder because I can't look in the source code to see where it's pulling the images from. Luckily, I have Firefox's LiveHTTPHeaders plugin.

LiveHTTPHeaders is a plugin that allows you to see all the calls that your browser makes. Whenever it pulls in a website, an image, a script, it will be logged here.

The SWF file still pulls in all it's images via AJAX(ish) calls. Now that i've found an area with some street view info i can see where it's getting the images from. Launch the HTTPHeader plugin -> Drag Street View around a bit to pull in new images -> View plugin logs.

Many of the urls called here are uninteresting. JS Callbacks, Arrow images, but we've hit gold with the urls accessing cbk (whatever that stands for)

Ex A: http://cbk0.google.com/cbk?output=tile&panoid=dFe0IGjaC3rLQGHUTChJDQ&zoom=3&x=5&y=2

Well what do we have here. It's a URL that gives us one frame of the panorama. It has a few parameters: output=tile, panoid=garbage, zoom=3, x=5, y=2. You'll notice that you can fiddle with different parameters. Changing x=? will turn the camera side to side and y=? will move it up and down. I'm guessing zoom will zoom in and out, but a lot of times they only offer one zoom. This is the key to hacking these things, just play around and see what makes it tick.

Cool! once we've got a location, we now know how to navigate around it. Now we just need to know how to find a location in the first place. It looks like we need to mess with panoid. My first guess was this was some type of hash of the lat/long values. It might be, but it's nothing we can generate. Luckily, with some googling for 'panoid' and google maps i stumbled across this URL.

Ex B: http://maps.google.com/cbk?output=xml&ll=37.4451,-122.125577

Voila, we give it a latitude and longitude, it gives us the pano_id. It also gives us some information on what we can do with it: zoom levels, what streets you're one, etc. But all i want from this now is the panoid.

So now we can take any latitude and longitude, plug it into example B, then take the pano_id from there and plug it into example A. If that location has street view data, we're golden.

Now, lat lons are a little user-unfriendly. Luckily most maps services offer a geolocation public API to convert addresses and places of interest to Lat/longs. I used http://geokit.rubyforge.org/, a rails plugin to do it. Since these APIs are public i'm not going to go into detail on how to use them, but once you have one working we can now go from

Address -> lat lon -> panoid -> Glorious street view data.

This isn't the most useful of experiments since there's only data in a few select areas, but it's cool to try out in san francisco and a few others. It will be much cooler when they get some serious coverage, but by then they'll have changed the API I'm sure.
If anyone writes a plugin or wrapper for this let me know!

8 comments:

Anonymous said...

Interesting essay. Research at its purist. I want more.

Anonymous said...

what kind of reverse engineer doesn't know about SWF decompilers?

The Meez said...

I know about them but a) they don't always work well and b) it was unnecessary.

Anonymous said...

This post is great. Especially that call that will reveal the panoid for a latlong pair.
Thank you!

Also here is a swf decompiler:
http://www.nowrap.de/flare.html
:)

Anonymous said...

Any hacks that have succeeded in replacing pano images in street view?

Shaun said...

i've been writing a python module wrapper for a lot of the google apis and used your tip on getting the pano_ids to finish it up :) i know google has its own python module it's released, but that module doesn't take advantage of things like getting street view jpgs or using google's calculator...

anyway, you said you wanted to see a wrapper if someone came up with one, and if you like, i could email you the entire module...

shauni3dud3 [at] gmail

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Anonymous said...

hey are you still trying how to get the GSV? let me know thanks.