November 23, 2009

Google Maps version 3 intellisense

Intellisense is one of those killer-features of Visual Studio. I love that I can just drop in an assembly in VS and start poking around in an editor to get a feel of the API. If the API i properly documented and layed out in a .netty way I can immediately start working with it.

The flipside of intellisense is that once you get used to it you feel severely limited when you encounter a project without intellisense. That's what happened to me today.

I was integrating the excellent Google Maps library into one of our websites and decided that I should use the latest and greatest release - Google Maps v3. I fired up VS and started hacking away in a .js file until i got flashbacks from back in the days when I developed PHP. I was toggling between writing code in my IDE and reading the api documentation in my browser. It was horrifying!

-vsdoc to the rescue

At some point I realized that since I can get intellisense for jQuery I should be able to get it for Google Maps as well so I started googling and found this single commit project at codeplex that did offer an intellisense file for Google Maps v2 but not for v3.

That's when I started looking at writing my own intellisense file. I tried to validate the Google API reference in the W3 Validator only to find out that the king of all web doesn't always produce the best markup.

Not to fear; I've written a couple of screen scraping utilities before and I know that there's one project that makes dealing with badly formatted html a breeze: Html Agility Pack. The agility pack parses almost any amount of bad markup and gives you a nice little XPath interface for poking around inside the DOM.

The result

After some hackish (screen scrapers are always messy) code I was able to produce a basic intellisense file that covers most of the Google Maps API.

The files

The js intellisense file and usage instructions can be found over at http://www.freakcode.com/projects/google-maps-v3-vsdoc.

kick it on DotNetKicks.com

Licensing information

5 comments:

  1. Hey, good stuff.

    I too build up intellisense files for Google and produced one recently with full API coverage. Can find it @ http://gmapvsdoc.codeplex.com/.

    I started writing a parser but just got fed up and knocked it out in UltraEdit in about 6 hours. Next time the API is updated I will probably build a parser.

    I too have nothing but good things to say about HTML agility pack.

    ReplyDelete
  2. I love it so far.
    It felt awkward blindly calling stuff and guessing it if will work or not. Ever worse I didn't have much javascript experience so....

    ReplyDelete
  3. correction:
    ^
    if it*
    Even*
    you get the picture.

    ReplyDelete
  4. Thanks to Markus for the generator and Thanks to sky for the guide
    I was able after some modifications to regenerate the whole page except for nested parsing callbacks which i did as well but requires some revision

    ReplyDelete