Index: modules/gmap/API.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/API.txt,v
retrieving revision 1.2
diff -u -r1.2 API.txt
--- modules/gmap/API.txt	7 May 2006 05:31:38 -0000	1.2
+++ modules/gmap/API.txt	12 Jun 2006 21:05:08 -0000
@@ -119,6 +119,28 @@
       'url' - the url of the feed.
       'markername' - the marker icon to use.  same as for markers
          except that numbered markers are not supported.
+  wmss - an array of WMS services arrays.  Each WMS service array can have the
+    following elements:
+      'name' - the name of the custom map (no spaces or special chars).
+      'url' - the url of the WMS service.
+      'format' - image format to retrieve. Depends of WMS service: 
+         'image/gif','image/png','image/jpeg'
+      'layers' - a comma separated list of layers advertized by WMS service
+         to show in this custom map.
+      'minresolution' - lowest zoom level of this custom map.
+      'maxresolution' - highest zoom level of this custom map.
+      'copyrights' - an array of copyrights to display. Each copyright array
+         can have the following elements:
+           'minzoom' - lowest zoom level at which this information applies.
+           'bounds' - a comma separated list of coordinates defining a 
+              region to which this copyright information applies: 'S,W,N,E'
+           'text' - text of the copyright message.
+      'overlaywith' - (optional) overlay WMS layers with this Google layers:
+         'Map', 'Hybrid', 'Satellite' or 'None'(default)
+      'merczoomlevel' - (optional) zoom factor of the google map where WMS service
+         should advertize layers in Transverse Mercator projection instead
+         of WGS84 projection. See discussion of this topic here:
+         http://johndeck.blogspot.com/#112679047816546118
 
 The gmap marker is converted to the javascript to display the map using the
 function gmap_draw_map($gmap, $javascript=''), where $gmap is a map
Index: modules/gmap/gmap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap.module,v
retrieving revision 1.30
diff -u -r1.30 gmap.module
--- modules/gmap/gmap.module	5 Jun 2006 06:59:25 -0000	1.30
+++ modules/gmap/gmap.module	12 Jun 2006 21:05:21 -0000
@@ -70,6 +70,7 @@
  *  track - a file containing a series of points in .plt format to be
  *  inserted into the node.
  *  feeds - an associative array of rss feeds
+ *  wmss - an associative array of WMS services
  *
  *  Xmaps must be enabled for circle and polygon to work.
  *
@@ -141,8 +142,80 @@
            
               function gmap_load_'.$gmap['id'].'() {
                  '.$gmap['id'].' = new GMap2($("'.$gmap['id'].'"));
-                 '.$gmap['id'].'.setCenter(new GLatLng('.$gmap['center'].'), '.$gmap['zoom'].');
                  ';
+
+    if (isset($gmap['wmss'])) {
+      $outtext.= '
+                 // WMS layers ';
+      $outtext.= '
+                 '.$gmap['id'].'.getMapTypes().length = 0;';
+      $ic=0;
+      foreach ($gmap['wmss'] as $item) {
+        $map_name = eregi_replace("[^a-z0-9_-]", "_", $item['name']);
+        (!isset($item['minresolution'])) ? $item['minresolution']='1': NULL;
+        (!isset($item['maxresolution'])) ? $item['maxresolution']='17': NULL;
+        (!isset($item['format'])) ? $item['format']='image/gif': NULL;
+        (!isset($item['merczoomlevel'])) ? $item['merczoomlevel']='5': NULL;
+
+        $outtext.= '        
+                 var ccol_'.$map_name.' = new GCopyrightCollection("'.$item['name'].'");
+        ';
+        if(isset($item['copyrights'])){
+          foreach ($item['copyrights'] as $copyright) {
+            (!isset($copyright['bounds'])) ? $copyright['bounds']='-190,-90,180,90': NULL;
+            (!isset($copyright['minzoom'])) ? $copyright['minzoom']='1': NULL;
+            (!isset($copyright['text'])) ? $copyright['text']='': NULL;
+            $coords = explode(",", $copyright['bounds']);
+            $outtext.= '
+                 var sw_'.$ic.' = new GLatLng('.$coords[0].','.$coords[1].',false);
+                 var ne_'.$ic.' = new GLatLng('.$coords[2].','.$coords[3].',false);
+                 var llb_'.$ic.' = new GLatLngBounds(sw_'.$ic.',ne_'.$ic.');
+                 var cr_'.$ic.' = new GCopyright(1,llb_'.$ic.','.$copyright['minzoom'].',"'.$copyright['text'].'");
+                 ccol_'.$map_name.'.addCopyright(cr_'.$ic.');
+            ';
+            $ic++;
+          }
+        }
+        $outtext.= '
+                 var t_'.$map_name.'= new GTileLayer(ccol_'.$map_name.','.$item['minresolution'].','.$item['maxresolution'].');
+                 t_'.$map_name.'.myMercZoomLevel='.$item['merczoomlevel'].';
+                 t_'.$map_name.'.myBaseURL=\''.$item['url'].'\';
+                 t_'.$map_name.'.myLayers=\''.$item['layers'].'\';
+                 t_'.$map_name.'.myFormat=\''.$item['format'].'\';
+                 t_'.$map_name.'.getTileUrl=CustomGetTileUrl;
+                 ';
+          if(isset($item['overlaywith'])){
+            switch (strtolower($item['overlaywith'])) {
+              case 'map':
+                      $outtext.= "var l_".$map_name."1=[G_NORMAL_MAP.getTileLayers()[0]]; \n                 ";
+                break;
+              case 'hybrid':
+                      //We overlay with roads only, not with the satellite imagery
+                      $outtext.= "var l_".$map_name."1=[G_HYBRID_MAP.getTileLayers()[1]]; \n                 ";
+                break;
+              case 'satellite':
+                      $outtext.= "var l_".$map_name."1=[G_SATELLITE_MAP.getTileLayers()[0]]; \n                 ";
+                break;
+              default:
+                      $outtext.= "var l_".$map_name."1=[]; \n                 ";
+            }
+          }
+        $outtext.= 'var l_'.$map_name.'2=[t_'.$map_name.'];
+                 var l_'.$map_name.'=l_'.$map_name.'2.concat(l_'.$map_name.'1);
+                 var m_'.$map_name.' = new GMapType(l_'.$map_name.', G_SATELLITE_MAP.getProjection(), "'.$item['name'].'", G_SATELLITE_MAP); 
+                 '.$gmap['id'].'.addMapType(m_'.$map_name.');
+                 ';
+      }
+      $outtext.= '
+                 '.$gmap['id'].'.addMapType(G_NORMAL_MAP);
+                 '.$gmap['id'].'.addMapType(G_SATELLITE_MAP);
+                 '.$gmap['id'].'.addMapType(G_HYBRID_MAP);
+                 ';
+    }
+                 
+    $outtext.= $gmap['id'].'.setCenter(new GLatLng('.$gmap['center'].'), '.$gmap['zoom'].');
+                 ';
+
     switch (strtolower($gmap['control'])) {
       case 'small':
         $outtext .='mycontrol=new GSmallMapControl();
@@ -515,6 +588,23 @@
         $gmap['feeds'][] = $tt;
         break;
 
+      case 'wmss':
+        unset($ttt);
+        $ttt = explode('+',$t[1]);
+        for ($i =0; $i<count($ttt); $i++) {
+          unset($tt);
+          list($tt['name'],$tt['url'],$tt['format'],$tt['layers'],$tt['minresolution'],$tt['maxresolution'],$tt['copyrights'],$tt['overlaywith'],$tt['merczoomlevel'])=explode('::',$ttt[$i]);
+          $crr = explode('/',$tt['copyrights']);
+          unset($tt['copyrights']);
+          for ($k =0; $k<count($crr); $k++) {
+            unset($cr);
+            list($cr['minzoom'],$cr['bounds'],$cr['text'])=explode(':',$crr[$k]);
+            $tt['copyrights'][]=$cr;
+          }
+          $gmap['wmss'][]=$tt;
+        }
+        break;
+
       case 'line1':
         $tt['color']=GMAP_LINECOLOR1;
       case 'line2':
@@ -666,6 +756,17 @@
       drupal_add_js('http://www.acme.com/javascript/Clusterer2.js');
     }
   }
+  if (GMAP_WMS){
+    if (file_exists('misc/wms-gs.js')) {
+      drupal_add_js('misc/wms-gs.js');
+    } elseif (file_exists('misc/wms236.js')) {
+      drupal_add_js('misc/wms236.js');
+    } elseif (file_exists('misc/wms-gs-1_0_0.js')) {
+      drupal_add_js('misc/wms-gs-1_0_0.js');
+    } else {
+      drupal_add_js('http://dist.codehaus.org/geoserver/gmaps-geoserver_scripts/wms-gs-1_0_0.js');
+    }
+  }
   if (file_exists('misc/gxmarker.2.js')){
       drupal_add_js('misc/gxmarker.2.js');
   }
@@ -925,6 +1026,7 @@
 //  $form['initialization']['gmap_xmaps']=array('#type'=>'checkbox', '#title'=>t('Enable Xmaps features (circles and polygons)'), '#default_value'=>GMAP_XMAPS,'#description'=>t('Enables XMaps features.  XMaps is currently a <em>beta</em> release available from <a href="http://xmaps.busmonster.com/">xmaps.busmonser.com</a>. '));
 //  $form['initialization']['gmap_xmaps_script']=array('#type' => 'textfield', '#title' => t('Location of XMaps script'), '#default_value'=>GMAP_XMAPS_SCRIPT, '#size' => 25, '#maxlength' => 50);
   $form['initialization']['gmap_cluster']=array('#type'=>'checkbox', '#title'=>t('Enable clusterer.js'), '#default_value'=>GMAP_CLUSTER,'#description'=>t('Enables Jef Poskanzer\'s excellent <a href="http://www.acme.com/javascript/#Clusterer">clusterer.js</a> script. (useful for a large number of markers on a single map)'));
+  $form['initialization']['gmap_wms']=array('#type'=>'checkbox', '#title'=>t('Enable wms236.js'), '#default_value'=>GMAP_WMS,'#description'=>t('Enables <a href="http://johndeck.blogspot.com/">John Deck\'s</a> <a href="http://johndeck.blogspot.com/#114071052432996324">wms236.js</a> <em>Call generic wms service for GoogleMaps v2</em> script. (to do OpenGeospatial WMS layering)'));
   $form['initialization']['gmap_on_click']=array('#type'=>'radios',
                                                  '#title'=>t('On Click Marker'),
                                                  '#default_value'=>variable_get('gmap_on_click',0),
