Patrick Matte Creative Coder

Creating a globe with Google Maps

I made some research on how to simulate Google Earth in Flash for a recent project at TBWA\Chiat\Day. Unfortunately the schedule was too tight and a freelancer was called in to build the module which in the end only used the regular google maps top view. But I wanted to share my research anyway.

The tricky thing is that the grid in Google Maps is square and as you can see in the background, the latitude is not distributed evenly. So you can’t simply take the square map and put it on a sphere or it will appear very distorted. What you need to do is find the latitude/longitude of the 4 vertices of every face on the sphere and then use the method fromLatLngToViewPort which returns the Point on the map that corresponds to that latitude and longitude.

Once you have all four points, you can draw that particular section of the map and use it as a material for the face. One thing worth mentioning is also that for some reason, the satellite view only has map available from 85 degrees to -85 degrees of latitude, so you have to patch the top and bottom of the sphere manually.

Maybe I’ll revisit this at a later time and make it possible zoom in on the map.

Download the source files.