Thursday, March 04, 2010

Automagically Bringing Up Street View, and Other Google Maps Hacks

Programmatically Linking to Google Maps is usually trivial. Just use a URL like so:

 starbucks+arlington+va
where the query startbucks+arlington+va is replaced by any text you want to search for. If you want, you can even plug in arbitrary latitude and longitude by saying: q=LAT,LNG where LAT and LNG are decimal latitude and longitude values.

But today, I wanted to link an admin tool I wrote to not just Google Maps, but the Street View of Google Maps.

At first I tried bringing up a particular map view, grabbing the link URL, and reverse engineering it. But given the randomish parameters, that quickly became a non-starter.

That's a good thing too, because one quick Google search brought me to someone asking the same exact question over at StackOverflow.com.

Listed in the answers was a link to this handy page: Google Map Parameters. Turns out, those random parameters I was tripping over aren't random at all. They're documented, and you're effectively encouraged to use them.

That's definitely a handy resource. It should even be handy to non-programmers who might have a blog or other web resource, and want to be able to get the most out of Google Maps. By constructing just the right URL, you should be able to get Google Maps to behave in a custom manner.

Incidentally, the simplest URL I came up with to jump to a particular map point with Street View on was:

http://maps.google.com/maps?q=LAT,LNG&layer=c&cbll=LAT,LNG&cbp=11,0,0,0,5

Where LAT and LNG are the latitude and longitude of the point you're requesting.

No comments:

Post a Comment