title: Using Google Maps v3 DrawingManager from GWT
body: <p>I am working on a project that uses GWT 2.4 and gwt-maps.jar to create a MapWidget and place it in a panel with various controls. This all works fine.</p>
  
  <p>I would like to give my users the ability to draw a polyline on the map and use the getLength method in Polyline to determine the length of the drawn polyline. I have done this before in ActionScript and it was a bit of a pain in the neck (the rubber-banding between the last clicked point and the mouse in particular) and I was hoping not to have to do that again.</p>
  
  <p>The drawing manager looks like it might be a good fit (for the drawing part at least) but it is in v3 of the API and the gwt-maps.jar code only is at v2. So I thought I might write some JavaScript and call out from GWT using JSNI, something along the lines of (in wibble.html - my top-level HTML file):</p>
  
  <pre><code>var dM = new google.maps.drawing.DrawingManager( ...
  
  function showDM(map) {
      dM.setMap(map);
      dM.setOptions({
          drawingControl: true
  });
  </code></pre>
  
  <p>And then (in Wobble.java):</p>
  
  <pre><code>private MapWidget map = new MapWidget( ...
  
  private native void showIt(final MapWidget map) /*-{
      $wnd.showDM(map);
  }-*/;
  </code></pre>
  
  <p>I have tried passing the MapWidget and its peer but in both cases I get an invalid value error when calling setMap.</p>
  
  <p>Has anybody tried (and succeeded) in doing this or am I barkig up the wrong tree?</p>
  
  <p>Thanks,</p>
  
  <p>SO</p>