title: WMS as a single tile image in Google Maps v3
body: <p>I am following the code at <a href="http://www.gisdoctor.com/v3/mapserver.html" rel="nofollow">http://www.gisdoctor.com/v3/mapserver.html</a> to overlay a WMS as an image on Google Maps using API v3. The js code at the above link is as follows</p>
  
  <pre><code>"WMSGetTileUrl" : function(tile, zoom) {
      var projection = map.getProjection();
      var zpow = Math.pow(2, zoom);
      var ul = new google.maps.Point(
          tile.x * 256.0 / zpow, 
          (tile.y + 1) * 256.0 / zpow
      );
      var lr = new google.maps.Point(
          (tile.x + 1) * 256.0 / zpow, 
          tile.y * 256.0 / zpow
      );
      var ulw = projection.fromPointToLatLng(ul);
      var lrw = projection.fromPointToLatLng(lr);
  
      var bbox = ulw.lng() + "," + ulw.lat() + "," + lrw.lng() + "," + lrw.lat();
  
      return url = "http://url/to/mapserver?" + 
          "version=1.1.1&amp;" + 
          "request=GetMap&amp;" + 
          "Styles=default&amp;" + 
          "SRS=EPSG:4326&amp;" + 
          "Layers=wmsLayers&amp;" + 
          "BBOX=" + bbox + "&amp;" + 
          "width=256&amp;" + 
          "height=256&amp;" + 
          "format=image/png&amp;" + 
          "TRANSPARENT=TRUE";
  },
  
  "addWmsLayer" : function() {
  
      /*
      Creating the WMS layer options. This code creates the Google 
      imagemaptype options for each wms layer. In the options the function 
      that calls the individual wms layer is set 
      */
      var wmsOptions = {
          alt: "MapServer Layers",
          getTileUrl: WMSGetTileUrl,
          isPng: false,
          maxZoom: 17,
          minZoom: 1,
          name: "MapServer Layer",
          tileSize: new google.maps.Size(256, 256)
      };
  
      /*
      Creating the object to create the ImageMapType that will call the WMS 
      Layer Options. 
      */
      wmsMapType = new google.maps.ImageMapType(wmsOptions);
      map.overlayMapTypes.insertAt(0, wmsMapType);
  },
  </code></pre>
  
  <p>Everything works fine, but, of course, the WMS is returned as 256 x 256 tiles. No surprises, because that is what I requested. However, following the discussion at <a href="http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c22837333f9a1812/d410a2a453025b38" rel="nofollow">http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c22837333f9a1812/d410a2a453025b38</a> it seems that I might be better off requesting an untiled (single) image from mapserver. This would tax my server less. In any case, I would like to experiment with a single image, but I am unable to construct a request for one properly.</p>
  
  <p>Specifically, I changed the size of the tile to something large; for example, I tried 1024 x 1024 tiles. I did get fewer tiles, but the returned images didn't match the Google Maps base layer boundaries.</p>
  
  <p>What I would like is to not specify the tile size at all. Instead, I should dynamically figure out the tile size to be, say, 256 pixels bigger than the current map size. That way, a single image would be returned, no matter what the map size. Also, a seamless pan would be implemented with the help of the extra 256px along the map edges.</p>
  
  <p>Suggestions?</p>