Sunday, August 03, 2008

Taking Google Maps API Offline

Sometimes, we want to utilize the some API for other work. Google Maps API is a very good example. You may want to use it as a photo viewer. Like allowing user to zoom-in and zoom-out, tagging, etc. However, since the API needs to validate the key online, you cannot take it as a standalone application where people can use offline.

Now, Google Maps API is a JavaScript API which we can download the script from the web. It just needs a bit hacking to get the API offline:
1. Highly obfuscated code
2. Dynamic module loading
3. Key verification

The obfuscated code can be ignored since you do not need to understand everything. All you need is finding the key statements that involve loading resources online (like module loading, image loading, etc). You can use a formatter to beautify it a little bit and decode it mentally.

The key verification is the most easiest part. Like all hacking, find the verification function and return a true will be good.

The process can be done within an hour for an experienced programmer.

With a good packager, we can have a really nice image mosaic viewer offline.