Why You Should Lie To Google Maps
Given that Google Maps isn't just your typical mapping experience, I've been pondering the possibilities of how it could be used to enhance desktop applications. Two apps that have already been enhanced by Google Maps come to mind right away: Address Book and Dashboard. In my opinion, both of these are great places for lacing in Google Maps, but I have to think that the best is yet to come. After all, when something becomes as pervasive as quickly as Google Maps did, it's just one of those commodities that people are going to start expecting to see everywhere -- not just on the web.
Fortunately for OS X developers, integrating Google Maps into your apps is cake. In fact, I almost decided not to even mention it -- but I couldn't resist because I thought the broader context of it all deserved some discussion.
Using WebKit, you can create a browser by writing only one line of code. Yes, ladies and gentlemen, it's true. Instead of reinventing the wheel here, however, take a look at the Mac DevCenter BYOB tutorial. When you build your own browser, you could go ahead and load up Google Maps right away, but it won't be a very friendly user experience. You'll be told that your browser isn't supported, and if you load the page anyway, you'll get slammed with intermittent messages like this one time and time again. Eventually, you'll risk losing your patience. Let's not go there.
"But Safari uses WebKit and it works fine on Google Maps. Why doesn't WebKit work when I try," you ask. Well, here's the thing: browsers send in a UserAgent string to each web server they talk to as part of the normal chatter that goes on. If you want to know what this string looks like, you can type this into your browser's address bar to see for yourself:
If you don't get a response, wrap it up in a simple HTML page and load it in the browser to get something back. It should look like this if you're using Safari:
Your homebrewed browser, on the other hand, gives you something like this:
You can see that Safari adds a little bit to the end, and Google Maps doesn't appreciate our homebrewed browser's non-compliance. Did you really think that Big Brother was the only one watching?!? Fortunately, we can care of things very easily, but we'll have to tell a lie to do it. Here goes, (ok, so it's more of a spoof than a lie.)
In the method call,
From here, you could do a lot of neat things to integrate Google Maps into your application. Remember that your user interface doesn't have to remotely resemble a web browser at all. Instead, you could load the content in the
Now, go give it a try.
Matthew Russell is a computer scientist from middle Tennessee; and serves Digital Reasoning Systems as the Director of Advanced Technology. Hacking and writing are two activities essential to his renaissance man regimen.