Monday, October 26, 2009

The best way to find what the current URL format Google uses

The best way to find what the current URL format Google uses is to visit Google Maps, and using either Firebug in Firefox or Web Inspector in Safari/Webkit you can inspect one of the tiles to get the image URL.



As of right now, here's an example of a Google Street Image URL in London, UK.



http://mt0.google.com/vt/lyrs=m@110&hl=en&x=4092&y=2724&z=13&s=



From the query string, we can see the x, y and z params that we need. The other stuff isn't needed. Plus as Google uses multiple servers, we don't need the "mt0" bit at the beginning, just "mt"



So that leaves us with.



http://mt.google.com/vt/x=4092&y=2723&z=13



But it's not quite right yet!



Maemo Mapper uses the "zoom" param instead of "z", as it uses 1 for the closest, up to 17. The "z" value is reversed by subtracting the "z" value from the maximum zoom.



Using the example above, this would mean that:



17 - 13 = 4

The "zoom" value would be 4, which would give us



http://mt.google.com/vt/x=4092&y=2723&zoom=4



Now to convert the URL into the format for Mapper



http://mt.google.com/vt/x=%d&y=$d&zoom=%d





The same approach can be used for the Satellite view.



An example using the same area



http://khm2.google.com/kh/v=46&x=4092&y=2723&z=13&s=Galileo



In this case, we would need the "v" param, the version, but the rest can go



http://khm.google.com/kh/v=46&x=4092&y=2723&z=13



Apply the same with the "zoom"



http://khm.google.com/kh/v=46&x=4092&y=2723&zoom=4



And convert to Mapper URL



http://khm.google.com/kh/v=46&x=%d&y=%d&zoom=%d





So after all that, as of now, here are the URLs



Google Street

http://mt.google.com/vt/x=%d&y=$d&zoom=%d



Google Satellite

http://khm.google.com/kh/v=46&x=%d&y=%d&zoom=%d





Hope that makes sense!

No comments:

Post a Comment