Geocoding with Mapstraction v2 and Google Maps v3

There isn’t a whole lot of info out there about how to use Mapstraction, especially the v2 API, so here’s one thing I’ve had to pick up along the way.

I spent a little time hacking together a geocoder module that uses the Google Maps v3 API, but was having to track down why it wasn’t loading properly. In the mxn.js file, there’s a note about how to activate various modules, but this isn’t clear in the Mapstraction v2 Sandbox on appspot. Here’s the comment:

Right, so to use the geocoding capabilities you need to do something like this in your HTML file:

Then you just do something like this:

And here’s the Geocoder plugin, developed with help from Google Chrome’s awesome Javascript Debugger (a definite notch above Venkman, and snappier):

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.