? gmap-info-files.patch
? gmap-jan03.patch
? gmap-jan04.patch
? gmap-jan06.patch
? gmap-jan2.patch
? gmap.info
? gmap.install
? gmap.js.save
? gmap2.js
? gmap2.js.save
? gmap_location.info
? info-files
? wms-gs-1_0_1.js
Index: gmap.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap.css,v
retrieving revision 1.3
diff -u -r1.3 gmap.css
--- gmap.css	27 May 2006 04:08:16 -0000	1.3
+++ gmap.css	7 Jan 2007 03:22:14 -0000
@@ -11,3 +11,16 @@
    margin: 0;
    border: solid black 1px;
 }
+
+.gmap-left {
+  float: left;
+}
+
+.gmap-center {
+  margin-left: auto;
+  margin-right: auto;
+}
+
+.gmap-right {
+  float: right;
+}
Index: gmap.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap.js,v
retrieving revision 1.13
diff -u -r1.13 gmap.js
--- gmap.js	19 Nov 2006 07:50:04 -0000	1.13
+++ gmap.js	7 Jan 2007 03:22:14 -0000
@@ -1,44 +1,450 @@
- 
 /* $Id: gmap.js,v 1.13 2006/11/19 07:50:04 webgeer Exp $ */
 
-var baseIcon=new Array();
-var geocoder = null;
- 
-function gmap_init() {
-  baseIcon['standard'] = new GIcon();
-  baseIcon['standard'].image = "http://www.google.com/mapfiles/marker.png";
-  baseIcon['standard'].shadow = "http://www.google.com/mapfiles/shadow50.png"
-  baseIcon['standard'].iconSize = new GSize(20, 34);
-  baseIcon['standard'].shadowSize = new GSize(37, 34);
-  baseIcon['standard'].iconAnchor = new GPoint(9, 34);
-  baseIcon['standard'].infoWindowAnchor = new GPoint(9, 2);
-  baseIcon['standard'].infoShadowAnchor = new GPoint(18, 25);
-   
-  baseIcon['big']=new GIcon();
-  baseIcon['big'].image= gmapMarkerLocation + "/big/blue.png";
-  baseIcon['big'].shadow=gmapMarkerLocation + "/big/shadow.png";
-  baseIcon['big'].iconsize=new GSize(30,51);
-  baseIcon['big'].shadowSize=new GSize(56,51);
-  baseIcon['big'].iconAnchor=new GPoint(13,34);
-  baseIcon['big'].infoWindowAnchor=new GPoint(13,3);
-  baseIcon['big'].infoShadowAnchor=new GPoint(27,37);
-   
-  baseIcon['small'] = new GIcon();
-  baseIcon['small'].image = gmapMarkerLocation + "/small/red.png";
-  baseIcon['small'].shadow = gmapMarkerLocation + "/small/shadow.png";
-  baseIcon['small'].iconSize = new GSize(12, 20);
-  baseIcon['small'].shadowSize = new GSize(22, 20);
-  baseIcon['small'].iconAnchor = new GPoint(6, 20);
-  baseIcon['small'].infoWindowAnchor = new GPoint(5, 1);
+Drupal.gmap = function() {
+  this.controls = {};
+  this.vars = {};
+  this.bindings = {};
+}
+
+Drupal.gmap.prototype.bind = function(name,callback) {
+  if(!this.bindings[name]) {
+    this.bindings[name] = new Array();
+  }
+  var n = this.bindings[name].length;
+  this.bindings[name][n] = callback;
+  return n;
+}
   
-  baseIcon['flat'] = new GIcon();
-  baseIcon['flat'].image = gmapMarkerLocation + "/flat/x.png";
-  baseIcon['flat'].shadow = "";
-  baseIcon['flat'].iconSize = new GSize(16, 16);
-  baseIcon['flat'].shadowSize = new GSize(0, 0);
-  baseIcon['flat'].iconAnchor = new GPoint(8, 8);
-  baseIcon['flat'].infoWindowAnchor = new GPoint(8, 8);
+Drupal.gmap.prototype.change = function(name,id) {
+  var s;
+  var i;
+  if (s = this.bindings[name]) {
+    for (i = 0 ; i < s.length ; i++) {
+      if (i != id) {
+//        alert(this.bindings[name][i]);
+//        alert(typeof(s[i]));
+        (this.bindings[name][i])();
+      }
+    }
+  }
+}
+
+  
+
+/////////////////// GEOCODING ////////////////////
+
+/**
+ * Provide a shared geocoder.
+ * Lazy initialize it so it's not resident until needed.
+ */
+Drupal.gmap.prototype.geocoder = function() {
+  var theGeocoder;
+  if (!theGeocoder) {
+    theGeocoder = new GClientGeocoder();
+    return theGeocoder;
+  }
+  else {
+    return theGeocoder;
+  }
+}
+
+//////////////////////// Markers ////////////////////////
+
+Drupal.gmap.prototype.markers = function(marker) {
+  var theMarkers;
+  if (!theMarkers) {
+    theMarkers = {};
+    var m = new GIcon();
+    m.image = "http://www.google.com/mapfiles/marker.png";
+    m.shadow = "http://www.google.com/mapfiles/shadow50.png";
+    m.iconSize = new GSize(20, 34);
+    m.shadowSize = new GSize(37,34);
+    m.iconAnchor = new GPoint(9,34);
+    m.infoWindowAnchor = new GPoint(9, 2);
+    m.infoShadowAnchor = new GPoint(18, 25);
+    theMarkers['standard'] = m;
+
+    m = new GIcon();
+    m.image = gmapMarkerLocation + "/big/blue.png";
+    m.shadow = gmapMarkerLocation + "/big/shadow.png";
+    m.iconsize=new GSize(30,51);
+    m.shadowSize=new GSize(56,51);
+    m.iconAnchor=new GPoint(13,34);
+    m.infoWindowAnchor=new GPoint(13,3);
+    m.infoShadowAnchor=new GPoint(27,37);
+    theMarkers['big'] = m;
+
+    m = new GIcon();
+    m.image = gmapMarkerLocation + "/small/red.png";
+    m.shadow = gmapMarkerLocation + "/small/shadow.png";
+    m.iconSize = new GSize(12, 20);
+    m.shadowSize = new GSize(22, 20);
+    m.iconAnchor = new GPoint(6, 20);
+    m.infoWindowAnchor = new GPoint(5, 1);
+    theMarkers['small'] = m;
+
+
+    m = new GIcon();
+    m.image = gmapMarkerLocation + "/flat/x.png";
+    m.shadow = "";
+    m.iconSize = new GSize(16, 16);
+    m.shadowSize = new GSize(0, 0);
+    m.iconAnchor = new GPoint(8, 8);
+    m.infoWindowAnchor = new GPoint(8, 8);
+    theMarkers['flat'] = m;
+
+    return theMarkers[marker];
+  }
+  else {
+    return theMarkers[marker];
+  }
+}
+
+
+
+
+
+Drupal.gmap.prototype.handler = {};
+
+/************************ Map widget *******************************/
+Drupal.gmap.prototype.handler.gmap = function(elem) {
+  var obj = this;
+  // Make it a gmap.
+  var map = new GMap2(elem);
+  map.addControl(new GMapTypeControl());
+//  map.setCenter(new GLatLng(obj.vars.lat, obj.vars.lon), obj.vars.zoom);
+//  map.setMapType(G_NORMAL_MAP);
+//  gmap_change_controltype(mapid,obj.vars.controltype);
+
+  obj.bind("init",function() {
+    map.setCenter(new GLatLng(obj.vars.lat,obj.vars.lon), obj.vars.zoom);
+  });
+
+
+  // Respond to incoming zooms
+  var binding = obj.bind("zoom",function(){map.setZoom(obj.vars.zoom)});
+  // Send out outgoing zooms
+  GEvent.addListener(elem, "zoomend", function(oldzoom,newzoom) {
+    obj.vars.zoom = newzoom;
+    obj.change("zoom",binding);
+  });
+  // Respond to incoming moves
+  binding = obj.bind("move",function(){map.panTo(new GLatLng(obj.vars.lat,obj.vars.lon))});
+  // Send out outgoing moves
+  GEvent.addListener(map,"moveend",function() {
+    var coord = map.getCenter();
+    obj.vars.lat = coord.lat();
+    obj.vars.lon = coord.lng();
+    obj.change("move",binding);
+  });
+
+  // Respond to incoming map type changes
+  binding = obj.bind("maptypechange",function(){
+    var type;
+    if(obj.vars.maptype=='Map') type = G_NORMAL_MAP;
+    if(obj.vars.maptype=='Hybrid') type = G_HYBRID_MAP;
+    if(obj.vars.maptype=='Satellite') type = G_SATELLITE_MAP;
+    map.setMapType(type);
+  });
+  // Send out outgoing map type changes.
+  GEvent.addListener(map,"maptypechanged",function() {
+    var type = map.getCurrentMapType();
+    if(type==G_NORMAL_MAP) obj.vars.maptype = 'Map';
+    if(type==G_HYBRID_MAP) obj.vars.maptype = 'Hybrid';
+    if(type==G_SATELLITE_MAP) obj.vars.maptype = 'Satellite';
+    obj.change("maptypechange",binding);
+  });
+
+  // Respond to incoming width changes.
+  binding = obj.bind("widthchange",function(){map.getContainer().style.width = obj.vars.width});
+  // Send out outgoing width changes.
+  // N/A
+  // Respond to incoming height changes.
+  binding = obj.bind("heightchange",function(){map.getContainer().style.height = obj.vars.height});
+  // Send out outgoing height changes.
+  // N/A
+
+
+  // Respond to incoming control type changes.
+  binding = obj.bind("controltypechange",function() {
+    if(obj.currentcontrol) {
+      map.removeControl(obj.currentcontrol);
+    }
+    if (obj.vars.controltype=='Small') map.addControl(obj.currentcontrol = new GSmallMapControl());
+    if (obj.vars.controltype=='Large') map.addControl(obj.currentcontrol = new GLargeMapControl());
+  });
+  // Send out outgoing control type changes.
+  // N/A
+
+  // Respond to incoming alignment changes.
+  binding = obj.bind("alignchange",function() {
+    var cont = map.getContainer();
+    $(cont)
+      .removeClass('gmap-left')
+      .removeClass('gmap-center')
+      .removeClass('gmap-right');
+    if (obj.vars.align=='Left')   $(cont).addClass('gmap-left');
+    if (obj.vars.align=='Center') $(cont).addClass('gmap-center');
+    if (obj.vars.align=='Right')  $(cont).addClass('gmap-right');
+  });
+  // Send out outgoing alignment changes.
+  // N/A
+    
+
+}
+
+/************* Zoom widget **************/
+Drupal.gmap.prototype.handler.zoom = function(elem) {
+  var obj = this;
+  // Respond to incoming zooms
+  var binding = obj.bind("zoom",function(){elem.value = obj.vars.zoom});
+  // Send out outgoing zooms
+  $(elem).change(function() {
+    obj.vars.zoom = parseInt(elem.value);
+    obj.change("zoom",binding);
+  });
+}
+
+/************** Latlong widget *************/
+Drupal.gmap.prototype.handler.latlong = function(elem) {
+  var obj = this;
+  // Respond to incoming movements.
+  var binding = obj.bind("move",function(){elem.value = ''+obj.vars.lat+','+obj.vars.lon});
+  // Send out outgoing movements.
+  $(elem).change(function() {
+    var t = this.value.split(',');
+    obj.vars.lat = t[0];
+    obj.vars.lon = t[1];
+    obj.change("move",binding);
+  });
+}
+
+/********************* Address widget ******************/
+Drupal.gmap.prototype.handler.address = function(elem) {
+  var obj = this;
+
+  // Respond to focus event.
+  $(elem).focus(function() {
+    this.value = '';
+  });
+
+  // Respond to incoming movements.
+  // Clear the box when the coords change...
+  var binding = obj.bind("move",function(){elem.value = 'Enter an address'});
+  // Send out outgoing movements.
+  // This happens ASYNC!!!
+  $(elem).change(function() {
+    if(elem.value.length > 0) {
+      obj.geocoder().getLatLng(elem.value,function(point) {
+        if(point) {
+          obj.vars.lat = point.lat();
+          obj.vars.lon = point.lng();
+          obj.change("move",binding);
+        }
+        else {
+          // Todo: Get translated value using settings.
+          elem.value = 'Geocoder error: Address not found';
+        }
+      });
+    }
+    else {
+      // Was empty. Ignore.
+      elem.value = 'Enter an address';
+    }
+  });
+}
+
+/********************* Maptype widget ******************/
+Drupal.gmap.prototype.handler.maptype = function(elem) {
+  var obj = this;
+  // Respond to incoming movements.
+  var binding = obj.bind("maptypechange",function(){elem.value = obj.vars.maptype});
+  // Send out outgoing movements.
+  $(elem).change(function() {
+    obj.vars.maptype = elem.value;
+    obj.change("maptypechange",binding);
+  });
+}
+
+/********************* Width widget *****************/
+Drupal.gmap.prototype.handler.width = function(elem) {
+  var obj = this;
+  // Respond to incoming width changes.
+  var binding = obj.bind("widthchange",function(){elem.value = obj.vars.width});
+  // Send out outgoing width changes.
+  $(elem).change(function() {
+    obj.vars.width = elem.value;
+    obj.change("widthchange",binding);
+  });
+}
+
+/********************* Height widget *****************/
+Drupal.gmap.prototype.handler.height = function(elem) {
+  var obj = this;
+  // Respond to incoming height changes.
+  var binding = obj.bind("heightchange",function(){elem.value = obj.vars.height});
+  // Send out outgoing height changes.
+  $(elem).change(function() {
+    obj.vars.height = elem.value;
+    obj.change("heightchange",binding);
+  });
+}
+
+/********************* Control type widget *****************/
+Drupal.gmap.prototype.handler.controltype = function(elem) {
+  var obj = this;
+  // Respond to incoming height changes.
+  var binding = obj.bind("controltypechange",function(){elem.value = obj.vars.controltype});
+  // Send out outgoing height changes.
+  $(elem).change(function() {
+    obj.vars.controltype = elem.value;
+    obj.change("controltypechange",binding);
+  });
+}
 
+/******************** Map ID widget ********************/
+Drupal.gmap.prototype.handler.mapid = function(elem) {
+  var obj = this;
+  // Respond to incoming map id changes.
+  var binding = obj.bind("idchange",function(){elem.value = obj.vars.id});
+  // Send out outgoing map id changes.
+  $(elem).change(function() {
+    obj.vars.id = elem.value;
+    obj.change("idchange",binding);
+  });
+}
+
+/******************** Macro widget ********************/
+Drupal.gmap.prototype.handler.macrotext = function(elem) {
+  var obj = this;
+  // We only really need one function...
+  var fn = function() {elem.value = obj.macro()};
+  // Bind to just about everything...
+  obj.bind("move",fn);
+  obj.bind("zoom",fn);
+  obj.bind("maptypechange",fn);
+  obj.bind("controltypechange",fn);
+  obj.bind("widthchange",fn);
+  obj.bind("heightchange",fn);
+  obj.bind("idchange",fn);
+  obj.bind("alignchange",fn);
+}
+
+/******************** Align widget ********************/
+Drupal.gmap.prototype.handler.alignment = function(elem) {
+  var obj = this;
+  // Respond to incoming alignment changes.
+  var binding = obj.bind("alignchange",function(){elem.value = obj.vars.align});
+  // Send out outgoing alignment changes.
+  $(elem).change(function() {
+    obj.vars.align = elem.value;
+    obj.change("alignchange",binding);
+  });
+}
+
+
+
+
+
+
+
+Drupal.gmapAutoAttach = function() {
+
+  // Init Google map facilities
+  if (Drupal.settings && Drupal.settings.gmap) {
+    for ( mapid in Drupal.settings.gmap ) {
+      var map = new Drupal.gmap();
+      map.vars = Drupal.settings.gmap[mapid];
+
+      if (map.vars.latlong && (!map.vars.lat || !map.vars.lon)) {
+        var t = map.vars.latlong.split(',');
+        map.vars.lat = t[0];
+        map.vars.lon = t[1];
+      }
+
+      for ( control in map.handler ) {
+        $('#gmap-'+mapid+'-'+control).each(function() {
+          map.handler[control].call(map,this);
+        });
+      }
+      map.change("init",-1);
+
+      // Send some changed events to fire up the rest of the initial settings..
+      map.change("maptypechange",-1);
+      map.change("controltypechange",-1);
+      map.change("alignchange",-1);
+
+    }
+  }
+}
+
+/**
+ * Get the current state as a macro.
+ */
+Drupal.gmap.prototype.macro = function() {
+  var o = '[gmap';
+  o+=' |zoom='    + this.vars.zoom;
+  o+=' |center='  + this.vars.lat+','+this.vars.lon;
+  o+=' |width='   + this.vars.width;
+  o+=' |height='  + this.vars.height;
+  o+=' |id='      + this.vars.id;
+  o+=' |control=' + this.vars.controltype;
+  // @@@ Use maptype instead, accept old and new.
+  o+=' |type='    + this.vars.maptype;
+  o+=' |align='   + this.vars.align;
+  if (this.vars.points.length > 0) {
+    o+=' |markers=' + this.vars.points.join(' + ');
+  }
+
+  // @@@ Wouldn't it be simpler to have an arbitrary # of lines?
+  if (this.vars.line1.length >0) o += ' |line1=' + this.vars.line1;
+  if (this.vars.line2.length >0) o += ' |line2=' + this.vars.line2;
+  if (this.vars.line3.length >0) o += ' |line3=' + this.vars.line3;
+
+  o+= ']';
+  return o;
+}
+
+/**
+ * @@@ Todo: Write one going the other way ;)
+ */
+
+
+/*
+  // Tie controls
+  $('.gmap-control').each(function() {
+    // Determine the specifics
+    var mapid = this.id.split('-');
+    var func = mapid.pop();
+    // Throw away the leading "gmap"
+    mapid.shift();
+    // The rest of it is our map id.
+    mapid = mapid.join('-');
+
+*/
+
+function gmap_validate_dim(dim) {
+  return dim;
+  //needs to be fixed to allow either 'px' or '%'
+  var reg = /(\d+)/;
+  var ar = reg.exec(dim);
+  try {
+    valid_dim = ar[0] + 'px';
+    return valid_dim;
+  } catch (e) {alert(e);
+    return false;
+  }
+}
+
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.gmapAutoAttach);
+}
+
+//////////////////// Old functions below the line /////////////////////
+
+var baseIcon=new Array();
+
+function gmap_init() {
 }
 
 function createIcon(marker) {
Index: gmap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap.module,v
retrieving revision 1.51
diff -u -r1.51 gmap.module
--- gmap.module	8 Dec 2006 08:13:07 -0000	1.51
+++ gmap.module	7 Jan 2007 03:22:14 -0000
@@ -10,43 +10,56 @@
  * html and javascript code required to insert a google map.
  */
 
-
 define('GMAP_LOAD_METHOD', variable_get('gmap_method','Static'));
-define('GMAP_WIDTH', variable_get('gmap_default_width', '300px'));
-define('GMAP_HEIGHT', variable_get('gmap_default_height', '200px'));
-define('GMAP_ZOOM', variable_get('gmap_default_zoom', 3));
-define('GMAP_CONTROL', variable_get('gmap_default_control', 'Small'));
+
+////define('GMAP_WIDTH', variable_get('gmap_default_width', '300px'));
+////define('GMAP_HEIGHT', variable_get('gmap_default_height', '200px'));
+////define('GMAP_ZOOM', variable_get('gmap_default_zoom', 3));
+////define('GMAP_CONTROL', variable_get('gmap_default_control', 'Small'));
 //define('GMAP_ALIGNMENT', variable_get('gmap_default_allignment', ???));
-define('GMAP_LONGLAT', variable_get('gmap_default_latlong', '40,0'));
-define('GMAP_TYPE', variable_get('gmap_default_type', 'Map'));
-define('GMAP_LINECOLOR1', variable_get('gmap_default_line1_color', '#00cc00'));
-define('GMAP_LINECOLOR2', variable_get('gmap_default_line2_color', '#ff0000'));
-define('GMAP_LINECOLOR3', variable_get('gmap_default_line3_color', '#0000ff'));
+////define('GMAP_LONGLAT', variable_get('gmap_default_latlong', '40,0'));
+////define('GMAP_TYPE', variable_get('gmap_default_type', 'Map'));
+
+
+// @@@ Remove these and generalize lines. @@@
+// These are now stored in the map defaults, but not all the code uses it yet.
+define('GMAP_LINECOLOR1', '#00cc00');
+define('GMAP_LINECOLOR2', '#ff0000');
+define('GMAP_LINECOLOR3', '#0000ff');
+// @@@ Remove these and generalize lines. @@@
+
+
 //define('GMAP_XMAPS', variable_get('gmap_xmaps',0));
 define ('GMAP_XMAPS',0); //xmaps not currently compatible with v2 of google maps api
 define('GMAP_XMAPS_SCRIPT', variable_get('gmap_xmaps_script','misc/xmaps.1c.js'));
 define('GMAP_CLUSTER', variable_get('gmap_cluster',0));
 define('GMAP_WMS', variable_get('gmap_wms',0));
 
-define('GMAP_API_V', '2.55a');
+define('GMAP_API_V', '2.66');
 
 /**
- * Implementation of hook_help.
- *
+ * Get the defaults for a gmap.
  */
-
-function gmap_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Filter to allow insertion of a google map into a node');
-  }
+function gmap_defaults() {
+  return variable_get('gmap_default', array(
+    'width' => '300px',
+    'height' => '200px',
+    'zoom' => 3,
+    'controltype' => 'Small',
+    'align' => 'None',
+    'latlong' => '40,0',
+    'maptype' => 'Map',
+    'line1_color' => '#00cc00',
+    'line2_color' => '#ff0000',
+    'line3_color' => '#0000ff',
+  ));
 }
 
+
+
 /**
  * Implementation of hook_perm.
- *
  */
-
 function gmap_perm() {
   return array('create macro');
 }
@@ -89,6 +102,16 @@
  *
  */
 function gmap_draw_map($gmap, $javascript='') {
+
+var_dump(xdebug_get_function_stack());
+
+echo "DRAW_MAP CALLED";
+
+//var_dump($gmap);
+return '';
+
+
+
   global $base_url, $node;
     _gmap_doheader();
     
@@ -99,18 +122,23 @@
       $gxmarkerjs=0;
     }
 
+    $defaults = array(
+      'autozoom' => FALSE,
+      'align' => '',
+      'tcontrol' => 'off',
+      'scontrol' => 'off',
+//    'ocontrol' => 'off',
+      'id' => 'map',
+      'drag' => 'yes',
+    );
+
+      
+
+    // prefer $gmap, then $defaults, then the global defaults..
+    $gmap = array_merge(gmap_defaults(),$defaults,$gmap);
+
     $clusterset=false;
-    (!isset($gmap['width'])) ? $gmap['width']=GMAP_WIDTH: NULL;
-    (!isset($gmap['height'])) ? $gmap['height']=GMAP_HEIGHT:NULL;
-    (!isset($gmap['zoom'])) ? $gmap['zoom']=GMAP_ZOOM:NULL;
-    (!isset($gmap['autozoom'])) ? $gmap['autozoom']=false:NULL;
-    (!isset($gmap['align'])) ? $gmap['align']='':NULL;
-    (!isset($gmap['id'])) ? $gmap['id']='map':NULL;
-    (!isset($gmap['control'])) ? $gmap['control']=GMAP_CONTROL:NULL;
-    (!isset($gmap['type'])) ? $gmap['type']=GMAP_TYPE:NULL;
-    (!isset($gmap['tcontrol'])) ? $gmap['tcontrol']='off':NULL;
-    (!isset($gmap['scontrol'])) ? $gmap['scontrol']='off':NULL;
-//    (!isset($gmap['ocontrol'])) ? $gmap['ocontrol']='off':NULL;
+
     (!isset($gmap['drag'])) ? $gmap['drag']='yes':NULL;
 
     if (!isset($gmap['latitude']) && !isset($gmap['center'])&& isset($gmap['latlong'])){
@@ -120,9 +148,10 @@
     elseif (!isset($gmap['latitude']) && isset($gmap['center'])){
       list($gmap['latitude'],$gmap['longitude']) =explode(',',$gmap['center']);
     }
-    elseif (!isset($gmap['latitude'])) {
-      list($gmap['latitude'],$gmap['longitude']) =explode(',',GMAP_LONGLAT);
-    }
+// This is not needed anymore due to the new defaults code.
+//    elseif (!isset($gmap['latitude'])) {
+//      list($gmap['latitude'],$gmap['longitude']) =explode(',',GMAP_LONGLAT);
+//    }
     $style='width: '.gmap_todim($gmap['width']).'; height: '.gmap_todim($gmap['height']).';';
 
 
@@ -138,8 +167,12 @@
         $style .= ' margin-left: auto; margin-right: auto;';
     }
 
+    
+// @@@ FIX THIS!
+
 //    $outtext .= "\n<!--\n\n".print_r($gmap, 1)."\n\n -->\n";
     $outtext.='<div id="'.$gmap['id'].'" style="'.$style.'" class="gmap-map"></div>
+
               <script type="text/javascript">
               //<![CDATA[
               //initialize global gmap variables
@@ -726,6 +759,13 @@
         $gmap['shape'][] = $tt;
         break;
 
+      case 'control':
+        $gmap['controltype'] = trim($t[1]);
+        break;
+
+      case 'type':
+        $gmap['maptype'] = trim($t[1]);
+        break;
 
       default:
         $gmap[trim($t[0])] = trim($t[1]);
@@ -753,22 +793,22 @@
  *
  */
 function gmap_set_location($map,&$form,$fields) {
-
+echo "FOO!";
   if (!is_array($map)){
     $map=gmap_parse_macro($map);
   }
   $zoom=$map['zoom'];
 
-  $form[$fields['latitude']]['#id']='gmap-latitude';
-  $form[$fields['latitude']]['#attributes']=array('onchange'=>'gmap_textchange('.$map['id'].');');
-  $form[$fields['longitude']]['#id']='gmap-longitude';
-  $form[$fields['longitude']]['#attributes']= array('onchange'=>'gmap_textchange('.$map['id'].');');
+  $form[$fields['latitude']]['#id']='gmap-'.$map['id'].'-latitude';
+//  $form[$fields['latitude']]['#attributes']=array('onchange'=>'gmap_textchange('.$map['id'].');');
+  $form[$fields['longitude']]['#id']='gmap-'.$map['id'].'-longitude';
+//  $form[$fields['longitude']]['#attributes']= array('onchange'=>'gmap_textchange('.$map['id'].');');
   if (isset($fields['address'])) {
-    $form[$fields['address']]['#id']='gmap-address';
-    $form[$fields['address']]['#attributes']= array('onchange'=>'gmap_geocodeaddress('.$map['id'].', this.value);');
+    $form[$fields['address']]['#id']='gmap-'.$map['id'].'-address';
+//    $form[$fields['address']]['#attributes']= array('onchange'=>'gmap_geocodeaddress('.$map['id'].', this.value);');
   }
 
-  if ($form[$fields['latitude']]['#default_value']!=0 || $form[$fields['longitude']]['#default_value']!=0) {
+/*  if ($form[$fields['latitude']]['#default_value']!=0 || $form[$fields['longitude']]['#default_value']!=0) {
     $myjava .= '{id}.panTo(new GLatLng('.$form[$fields['latitude']]['#default_value'].', '.$form[$fields['longitude']]['#default_value'].'));'."\n".
              '{id}.addOverlay(thispoint=new GMarker(new GLatLng('.$form[$fields['latitude']]['#default_value'].', '.$form[$fields['longitude']]['#default_value'].')));'."\n";
   }
@@ -796,6 +836,7 @@
                 });
                // GEvent.addListener({id}, "dragend", function() {{id}.checkResize();} )
               ';
+*/
   $out = gmap_draw_map($map,$myjava);
   
 
@@ -810,8 +851,7 @@
 
   $gmap_path = drupal_get_path('module','gmap');
 
-  theme_add_style($gmap_path. '/gmap.css');
-  drupal_add_js('misc/drupal.js');
+  drupal_add_css($gmap_path .'/gmap.css');
   drupal_add_js($gmap_path. '/gmap.js');
   $js = '<script src="http://maps.google.com/maps?file=api&amp;v='.GMAP_API_V.'&amp;key='.variable_get('googlemap_api_key', '').'" type="text/javascript"></script>';
   drupal_set_html_head($js);
@@ -861,7 +901,7 @@
     else {
       $ver=2;
     }
-    $out[1][$i] = gmap_draw_map(gmap_parse_macro($matches[1][$i],$ver));
+    $out[1][$i] = theme('gmap',array('#settings'=>gmap_parse_macro($matches[1][$i],$ver)));
     $i++;
   } // endwhile process macro
   return $out;
@@ -914,7 +954,6 @@
       return $text;
 
     case 'no cache':
-    
       return (variable_get('gmap_method', 'Static')=='Dynamic');
   }
 }
@@ -940,9 +979,18 @@
       'access' => user_access('create macro')||user_access('show user map')||user_access('show node map'),
     );  */
     $items[] = array(
+      'path' => 'admin/settings/gmap',
+      'title' => t('GMap'),
+      'description' => t('Configure GMap settings'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => 'gmap_admin_settings',
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_NORMAL_ITEM,
+    );
+    $items[] = array(
       'path' => 'map/macro',
       'type' => MENU_NORMAL_ITEM,
-      'title' => t('build a GMap macro'),
+      'title' => t('Build a GMap macro'),
       'access' => user_access('create macro'),
       'callback' => 'gmap_macro_page',
     );
@@ -955,147 +1003,134 @@
   return $items;
 }
 
-function gmap_settings() {
+function gmap_admin_settings() {
   //note the same google api key variable name as in the googlemap module is used
   //note the name of the variable for center of the map is latlong although the format is actually longitude, latitude
 
-  $form['initialization']=array(
+  $form['initialization'] = array(
     '#type' => 'fieldset',
     '#title' => t('Google Map Initialize'),
   );
-  $form['initialization']['googlemap_api_key']=array(
+  $form['initialization']['googlemap_api_key'] = array(
     '#type' => 'textfield', 
     '#title' => t('Google map API key'),
-    '#default_value'=>variable_get('googlemap_api_key', ''), 
+    '#default_value' => variable_get('googlemap_api_key', ''), 
     '#size' => 50, 
     '#maxlength' => 255,
     '#description' => t('Your personal Googlemaps API key.  You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.'),
   );
-  $form['initialization']['gmap_method']=array(
+  $form['initialization']['gmap_method'] = array(
     '#type' => 'select',
     '#title' => t('Google map method'),
     '#options'=> array('Static'=>t('Static'), 'Dynamic'=>t('Dynamic'), 'None'=>t('None')),
-    '#default_value'=>GMAP_LOAD_METHOD,
+    '#default_value' => GMAP_LOAD_METHOD,
     '#description' => t('How is the Google Map initialization script run:<br /><strong>Static</strong> - Loaded on every page, <br /><strong>Dynamic</strong> - Initialization script runs only on pages with google maps, but all pages with the gmap filter will not be cached. <br /><strong>None</strong> - Google map initialization script must be loaded some other way.'),
   );
-  // xmaps not compatible with v2 of the Google Map API
-  /*
-  $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_wms']=array(
+  $form['initialization']['gmap_wms'] = array(
     '#type'=>'checkbox',
     '#title'=>t('Enable wms features'),
     '#default_value'=>GMAP_WMS,
     '#description'=>t('Enables the wms features.  This allows you to use overlays that are defined using wms.  The wms-gs.js (or other acceptable version) must be installed in the gmap directory.'),
   );
-
-  $form['initialization']['gmap_on_click']=array(
-    '#type'=>'radios',
-                                                 '#title'=>t('On Click Marker'),
-                                                 '#default_value'=>variable_get('gmap_on_click',0),
-                                                 '#options'=>array(t('Open info window'), t('Open link')),
+  $form['initialization']['gmap_on_click'] = array(
+    '#type' => 'radios',
+    '#title' => t('On Click Marker'),
+    '#default_value' => variable_get('gmap_on_click',0),
+    '#options'=>array(t('Open info window'), t('Open link')),
     '#description'=>t('For markers that have link associated with them, it can either an info window or go directly to the link.'),
   );
 
-  $form['defaults']=array(
+  $defaults = gmap_defaults();
+
+  $form['gmap_default'] = array(
     '#type' => 'fieldset',
     '#title' => t('Default map settings'),
+    // This will store all the defaults in one variable.
+    '#tree' => TRUE,
+  );
+  $form['gmap_default']['width'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default width'),
+    '#default_value' => $defaults['width'],
+    '#size' => 25,
+    '#maxlength' => 6,
+    '#description' => t('The default width of a Google map.'),
+  );
+  $form['gmap_default']['height'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default height'),
+    '#default_value' => $defaults['height'],
+    '#size' => 25,
+    '#maxlength' => 6,
+    '#description' => t('The default height of a Google map.'),
   );
-  $form['defaults']['gmap_default_width']=array(
-    '#type'=>'textfield',
-    '#title'=>t('Default width'),
-    '#default_value'=>GMAP_WIDTH,
-    '#size'=>25,
-    '#maxlength'=>6,
-    '#description'=>t('The default width of a Google map.'),
-  );
-  $form['defaults']['gmap_default_height']=array(
-    '#type'=>'textfield',
-    '#title'=>t('Default height'),
-    '#default_value'=>GMAP_HEIGHT,
-    '#size'=>25,
-    '#maxlength'=>6,
-    '#description'=>t('The default height of a Google map.'),
-  );
-  $form['defaults']['gmap_default_latlong']=array(
-    '#type'=>'textfield',
-                                                  '#title'=>t('Default center'),
-                                                  '#default_value'=>GMAP_LONGLAT,
-                                                  '#description'=>'The decimal latitude,longitude of the centre of the map.  The "." is used for decimal, and "," is used to separate latitude and longitude.',
-    '#size'=>50,
-    '#maxlength'=>255,
-    '#description'=>t('The default longitude, latitude of a Google map.'),
-  );
-  $form['defaults']['gmap_default_zoom']=array(
-    '#type'=>'select',
-    '#title'=>t('Default zoom'),
-    '#default_value'=>GMAP_ZOOM,
+  $form['gmap_default']['latlong'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default center'),
+    '#default_value' => $defaults['latlong'],
+    // @@@ This gets overwritten right away. Move into the help hook or something.
+    '#description' => t('The decimal latitude,longitude of the centre of the map. The "." is used for decimal, and "," is used to separate latitude and longitude.'),
+    '#size' => 50,
+    '#maxlength' => 255,
+    '#description' => t('The default longitude, latitude of a Google map.'),
+  );
+  $form['gmap_default']['zoom'] = array(
+    '#type' => 'select',
+    '#title' => t('Default zoom'),
+    '#default_value' => $defaults['zoom'],
     '#options' => drupal_map_assoc(range(0, 17)),
-    '#description'=>t('The default zoom level of a Google map.'),
+    '#description' => t('The default zoom level of a Google map.'),
   );
-  $form['defaults']['gmap_default_control']=array(
-    '#type'=>'select',
-    '#title'=>t('Default control type'),
-    '#default_value'=>GMAP_CONTROL,
-    '#options'=>array('None'=>t('None'),'Small'=>t('Small'),'Large'=>t('Large')),
-  );
-  $form['defaults']['gmap_default_type']=array(
-    '#type'=>'select',
-    '#title'=>t('Default map type'),
-    '#default_value'=>GMAP_TYPE,
-    '#options'=>array('Map'=>t('Map'),'Satellite'=>t('Satellite'),'Hybrid'=>t('Hybrid')),
-  );
-  $form['defaults']['gmap_default_line1_color']=array(
-    '#type'=>'textfield',
-    '#title'=>t('Default Line 1 Color'),
-    '#default_value'=>GMAP_LINECOLOR1,
-    '#size'=>25,
-    '#maxlength'=>7 ,
-  );
-  $form['defaults']['gmap_default_line2_color']=array(
-    '#type'=>'textfield',
-    '#title'=>t('Default Line 2 Color'),
-    '#default_value'=>GMAP_LINECOLOR2,
-    '#size'=>25,
-    '#maxlength'=>7 ,
-  );
-  $form['defaults']['gmap_default_line3_color']=array(
-    '#type'=>'textfield',
-    '#title'=>t('Default Line 3 Color'),
-    '#default_value'=>GMAP_LINECOLOR3,
-    '#size'=>25,
-    '#maxlength'=>7 ,
+  $form['gmap_default']['controltype'] = array(
+    '#type' => 'select',
+    '#title' => t('Default control type'),
+    '#default_value' => $defaults['controltype'],
+    '#options' => array('None' => t('None'),'Small' => t('Small'),'Large' => t('Large')),
+  );
+  $form['gmap_default']['maptype'] = array(
+    '#type' => 'select',
+    '#title' => t('Default map type'),
+    '#default_value' => $defaults['maptype'],
+    '#options' => array('Map' => t('Map'),'Satellite' => t('Satellite'),'Hybrid' => t('Hybrid')),
+  );
+  $form['gmap_default']['line1_color'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default Line 1 Color'),
+    '#default_value' => $defaults['line1_color'],
+    '#size' => 25,
+    '#maxlength' => 7,
+  );
+  $form['gmap_default']['line2_color'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default Line 2 Color'),
+    '#default_value' => $defaults['line2_color'],
+    '#size' => 25,
+    '#maxlength' => 7 ,
   );
-  $markers=gmap_get_markers();
+  $form['gmap_default']['line3_color'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default Line 3 Color'),
+    '#default_value' => $defaults['line3_color'],
+    '#size' => 25,
+    '#maxlength' => 7 ,
+  );
+  $markers = gmap_get_markers();
 
-  $form['clusterer']=array(
+  $form['clusterer'] = array(
     '#type' => 'fieldset',
     '#title' => t('Clusterer settings'),
   );
-  $form['clusterer']['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).  This must be installed in the gmap directory of the drupal install.'),
+  $form['clusterer']['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).  This must be installed in the gmap directory of the drupal install.'),
   );
   $form['clusterer']['gmap_cluster_marker'] = array(
-    '#type'=>'select',
-    '#title'=>t('Marker for clusters'),
-    '#default_value'=>variable_get('gmap_cluster_marker', 'cluster'),
-    '#options'=>$markers,
+    '#type' => 'select',
+    '#title' => t('Marker for clusters'),
+    '#default_value' => variable_get('gmap_cluster_marker', 'cluster'),
+    '#options' => $markers,
   );
   $form['clusterer']['gmap_cluster_max_markers'] = array(
     '#type' => 'textfield',
@@ -1120,121 +1155,197 @@
     '#maxlength' => 2,
   );
 
-  $form['location']=array(
+  $form['location'] = array(
     '#type' => 'fieldset',
     '#title' => t('Location settings'),
   );
-  $form['location']['gmap_location_map']=array(
-    '#type'=>'textfield',
-                                           '#title'=>t('Default location map'),
-                                           '#default_value'=>variable_get('gmap_location_map','[gmap|id=locmap|center=40,0|zoom=3|width=100%|height=400px]'),
-                                           '#size'=>50,
-    '#description'=>t('The gmap macro for the map to be used in the location.module for setting latitude and longitude.'),
+  $form['location']['gmap_location_map'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Default location map'),
+    '#default_value' => variable_get('gmap_location_map','[gmap|id=locmap|center=40,0|zoom=3|width=100%|height=400px]'),
+    '#size' => 50,
+    '#description' => t('The gmap macro for the map to be used in the location.module for setting latitude and longitude.'),
   );
-  return $form;
+  return system_settings_form($form);
 }
 
 function gmap_macro_page() {
   drupal_add_js(drupal_get_path('module','gmap'). '/gmapmacro.js');
   _gmap_doheader();
-  return gmap_macro_form();
+  return drupal_get_form('gmap_macro_form');
+}
+
+/**
+ * Implementation of hook_elements().
+ */
+function gmap_elements() {
+  return array(
+    'gmap' => array(
+      '#input' => FALSE, // This isn't a *form* input!!
+      '#id' => 'map',
+      '#settings' => array_merge(gmap_defaults(),array(
+        'id' => 'map', // @@@ I hate this.
+        'points' => array(),
+        'pointsOverlays' => array(),
+        'line1' => array('overlay' => null, 'points' => null, 'line' => ""),
+        'line2' => array('overlay' => null, 'points' => null, 'line' => ""),
+        'line3' => array('overlay' => null, 'points' => null, 'line' => ""),
+      )),
+      '#process' => array('expand_gmap' => array()),
+    ),
+  );
+}
+
+/**
+ * Gmap element process hook
+ */
+function expand_gmap($element) {
+  $element['#settings'] = array_merge(gmap_defaults(),array(
+    'id' => 'map', // @@@ I hate this.
+    'points' => array(),
+    'pointsOverlays' => array(),
+    'line1' => array('overlay' => null, 'points' => null, 'line' => ""),
+    'line2' => array('overlay' => null, 'points' => null, 'line' => ""),
+    'line3' => array('overlay' => null, 'points' => null, 'line' => ""),
+  ),$element['#settings']);
+  return $element;
 }
 
+/**
+ * Gmap element theme hook
+ */
+function theme_gmap($element) {
+//var_dump($element);
+  $map = array_merge(gmap_defaults(),$element['#settings']);
+  $element['#attributes']['class'] = trim(implode(' ',array($element['#attributes']['class'],'gmap','gmap-map')));
+  if (!isset($element['#id'])) {
+    $element['#id'] = $map['id'];
+  }
+  if (!isset($map['id'])) {
+    $map['id'] = $element['#id'];
+  }
+  $o = '<div id="gmap-'.$element['#id'].'-gmap" style="width: '.$map['width'].'; height: '.$map['height'].';" class="'.$element['#attributes']['class'].'"></div>';
+
+  // Inline settings extend.
+  $o .= '<script type="text/javascript">Drupal.extend({ settings: '.drupal_to_js(array('gmap' => array($element['#id'] => $map)))." });</script>\n"; 
+//  $o .= drupal_add_js(array('gmap' => array($element['#id'] => $map)),'setting','inline');
+  return $o;
+}
+  
+
 function gmap_macro_form() {
-        $form['macroform'] = array(
+  $form['macroform'] = array(
     '#type' => 'fieldset',
     '#title' => t('Gmap macro creation'),
     '#theme' => 'gmap_macro',
   );
   $linecolors = array(GMAP_LINECOLOR1, GMAP_LINECOLOR2, GMAP_LINECOLOR3); 
+
   $form['macroform']['mapdiv'] = array(
-    '#type'   => 'markup',
-    '#value'  => '<div id="map" style="width: '.GMAP_WIDTH.'; height: '.GMAP_HEIGHT.';" class="gmap-map"></div>'
-  );
-  $form['macroform']['javascript'] = array(
-    '#value' => drupal_call_js('gmap_set_line_colors', $linecolors),
+    '#type' => 'gmap',
+    '#id' => 'map',
+    '#settings' => array(
+      'points' => array(),
+      'pointsOverlays' => array(),
+    ),
   );
+
+// Todo: Change this to a setting.
+drupal_add_js('gmap_set_line_colors("'.implode('","',$linecolors).'")','inline');
+
+//drupal_to_js(array('gmap'=>$settings),'setting');
+
+  $defaults = gmap_defaults();
+
   $form['macroform']['mapid'] = array(
     '#type' => 'textfield',
-    '#id' => 'gmap-mapid',
+    '#id' => 'gmap-map-mapid',
     '#title' => t('Map id attribute'),
     '#default_value' => variable_get('gmap_default_mapid', 'map'),
-    '#attributes' => array('onchange' => 'set_gmap_mapid(this.value)'),
+    '#attributes' => array('class' => 'gmap-control'),
   );
   $form['macroform']['maptype'] = array(
     '#type' => 'select', 
-    '#id' => 'gmap-maptype',
+    '#id' => 'gmap-map-maptype',
     '#title' => t('Map type'), 
     '#options' => drupal_map_assoc(array('Map', 'Satellite', 'Hybrid')), 
-    '#default_value' => GMAP_TYPE,
+    '#default_value' => $defaults['maptype'],
     '#required' => FALSE,
-    '#attributes' => array('onchange' => 'set_gmap_type(this.value);'),
+    '#attributes' => array('class' => 'gmap-control'),
   );
   $form['macroform']['controltype'] = array(
     '#type' => 'select', 
-    '#id' => 'gmap-controltype',
+    '#id' => 'gmap-map-controltype',
     '#title' => t('Controls'), 
     '#options' => drupal_map_assoc(array('None', 'Small', 'Large')), 
     '#required' => FALSE,
-    '#default_value' => GMAP_CONTROL,
-    '#attributes' => array('onchange' => 'set_control_type(this.value);')
-  );  
+    '#default_value' => $defaults['controltype'],
+    '#attributes' => array('class' => 'gmap-control'),
+  );
+  $form['macroform']['address'] = array(
+    '#type' => 'textfield',
+    '#id' => 'gmap-map-address',
+    '#title' => t('Address'),
+    '#default_value' => '',
+    '#attributes' => array('class' => 'gmap-control'),
+  );
   $form['macroform']['latlong'] = array(
     '#type' => 'textfield',
-    '#id' => 'gmap-latlong',
+    '#id' => 'gmap-map-latlong',
     '#title' => t('The Latitude and Longitude of the centre of the map'),
-    '#default_value' => GMAP_LONGLAT,
+    '#default_value' => $defaults['latlong'],
     '#size' => 50,
-    '#attributes' => array('onchange' => 'set_gmap_latlong(this.value);'),
+    '#attributes' => array('class' => 'gmap-control'),
   );
   $form['macroform']['width'] = array(
     '#type' => 'textfield',
-    '#id' => 'gmap-width',
+    '#id' => 'gmap-map-width',
     '#title' => t('Map width'),
-    '#default_value' => GMAP_WIDTH,
+    '#default_value' => $defaults['width'],
     '#size' => 25,
-    '#attributes' => array('onchange' => 'set_gmap_dimension(this, \'width\');'),
+    '#attributes' => array('class' => 'gmap-control'),
   ); 
   $form['macroform']['height'] = array(
     '#type' => 'textfield',
+    '#id' => 'gmap-map-height',
     '#title' => t('Map height'),
-    '#id' => 'gmap-height',
-    '#default_value' => GMAP_HEIGHT,
+    '#default_value' => $defaults['height'],
     '#size' => 25,
-    '#attributes' => array('onchange' => 'set_gmap_dimension(this, \'height\');'),
+    '#attributes' => array('class' => 'gmap-control'),
   ); 
   $form['macroform']['alignment'] = array(
     '#type' => 'select', 
-    '#id' => 'gmap-alignment',
+    '#id' => 'gmap-map-alignment',
     '#title' => t('Alignment'), 
     '#options' => drupal_map_assoc(array('None', 'Right', 'Left', 'Center')), 
 //    '#default_value' => GMAP_ALIGNMENT,
     '#required' => FALSE,
-    '#attributes' => array('onchange' => 'set_gmap_alignment(this.value);')
+    '#attributes' => array('class' => 'gmap-control'),
   );  
   $form['macroform']['clicktype'] = array(
     '#type' => 'select', 
-    '#id' => 'gmap-clicktype',
+    '#id' => 'gmap-map-clicktype',
     '#title' => t('What happens when you click on the map'), 
     '#options' => drupal_map_assoc(array('Points', 'Line1', 'Line2', 'Line3')), 
     '#required' => FALSE,
     '#default_value' => 'Points',
-//    '#attributes' => array('onchange' => 'docontrol(this.value);')
+    '#attributes' => array('class' => 'gmap-control'),
   );    
   $form['macroform']['zoom'] = array(
     '#type' => 'select', 
-    '#id' => 'gmap-zoom',
+    '#id' => 'gmap-map-zoom',
     '#title' => t('The current magnification of the map'),
-    '#default_value' => GMAP_ZOOM,
+    '#default_value' => $defaults['zoom'],
     '#options' => drupal_map_assoc(range(0, 17)),
-    '#attributes' => array('onchange' => 'setgmapZoom(this.value);'),
+    '#attributes' => array('class' => 'gmap-control'),
   );
   $form['macroform']['textarea'] = array(
     '#type' => 'textarea',
-    '#id' => 'gmap-macrotext',
+    '#id' => 'gmap-map-macrotext',
     '#title' => t('Macro text'),
+    '#attributes' => array('class' => 'gmap-control'),
   );
-  return drupal_get_form('macroform', $form);
+  return $form;
 }
 
 /**
@@ -1247,7 +1358,8 @@
       'theme' => 'views_view_gmap',
       'needs_fields' => true,
       'validate' => 'views_ui_plugin_validate_list',
-  ));
+    )
+  );
 }
 
 function gmap_get_markers(){
@@ -1284,10 +1396,12 @@
       foreach ($view->field as $field) {
         $marker_label .= '<div class="'. $field['field'] .'">'. views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) .'</div>';
       }
-      $markers[] = array('markername' => variable_get('gmap_node_marker_'.$node_data->type, ''),
-                         'label' => strtr($marker_label,"'\n\r",'" '),
-                         'latitude' => $location['lat'],
-                         'longitude' => $location['lon']);
+      $markers[] = array(
+        'markername' => variable_get('gmap_node_marker_'.$node_data->type, ''),
+        'label' => strtr($marker_label,"'\n\r",'" '),
+        'latitude' => $location['lat'],
+        'longitude' => $location['lon']
+      );
     }
   }
   $thismap = array('id' => 'view_gmap', 'markers' => $markers);
Index: gmap_location.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap_location.module,v
retrieving revision 1.26
diff -u -r1.26 gmap_location.module
--- gmap_location.module	8 Dec 2006 08:14:35 -0000	1.26
+++ gmap_location.module	7 Jan 2007 03:22:14 -0000
@@ -10,46 +10,32 @@
  */
 
 /**
- * Implementation of hook_help.
- *
- */
-
-function gmap_location_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Display location.module information on Google Maps (needs gmap.module)');
-  }
-}
-
-/**
- * Implementation of hook_perm.
- *
+ * Implementation of hook_perm().
  */
-
 function gmap_location_perm() {
   return array('set user location', 'show user map', 'user locations', 'show node map');
 }
 
 /**
- * Implementation of hook_menu.
+ * Implementation of hook_menu().
  *
  */
-
 function gmap_location_menu($may_cache) {
-  $items=array();
+  $items = array();
 
   if ($may_cache) {
     $items[] = array(
       'path' => 'map/user',
-        'type' => MENU_NORMAL_ITEM,
-      'title' => t('user locations'),
-        'access' => user_access('show user map'),
+      'type' => MENU_NORMAL_ITEM,
+      'title' => t('User locations'),
+      'access' => user_access('show user map'),
       'callback' => 'gmap_location_user_page'
     );
-      $items[] = array('path' => 'map/node',
-        'type' => MENU_NORMAL_ITEM,
-      'title' => t('node locations'),
-        'access' => user_access('show node map'),
+    $items[] = array(
+      'path' => 'map/node',
+      'type' => MENU_NORMAL_ITEM,
+      'title' => t('Node locations'),
+      'access' => user_access('show node map'),
       'callback' => 'gmap_location_node_page'
     );
   }
@@ -61,10 +47,9 @@
  * Draws a page with a google map that has all of the site users.
  *
  */
-
 function gmap_location_user_page() {
   global $user;
-  $locationbyuser=array();
+  $locationbyuser = array();
 
   $output ='<p>'.variable_get('gmap_user_map_header', t('This map illustrates the extent of users of this website. Each marker indicates a user that has entered their locations.'))."</p>\n";
 
@@ -80,6 +65,8 @@
     }
   }
 
+  $thismap = array();
+
   $thismap = gmap_parse_macro(variable_get('gmap_user_map', '[gmap|id=usermap|center=30,0|zoom=2|width=100%|height=400px]'));
   if (empty($thismap['markers'])) {
     $thismap['markers']=array();
@@ -131,8 +118,15 @@
       }
     }
   }
+
+  $element = array(
+    '#type' => 'gmap',
+    '#settings' => $thismap
+  );
+
+  $output .= theme('gmap',$element);
   
-  $output .= '<p>'.gmap_draw_map($thismap);
+//  $output .= '<p>'.gmap_draw_map($thismap);
   if ($user->uid>0) {
     $output .= '<p>'.t('To add/change your location to the user map, ').l(t('edit your location'),'user/'.$user->uid.'/edit/gmap_user');
   }
@@ -145,8 +139,6 @@
  * @param $nn
  * The node number to draw on the map.  If this is not set, or is null then all of the nodes will be drawn.
  */
-
-
 function gmap_location_node_page($nid=null) {
   if ($nid && $n=node_load($nid)){
     if (node_access('view',$n)) {
@@ -175,7 +167,12 @@
     }
   }
 
-  $output .= '<p>'.gmap_draw_map($thismap);
+//  $output .= '<p>'.gmap_draw_map($thismap);
+
+  var_dump($thismap);
+
+  $output .= '<p>'.theme('gmap',array('#settings'=>$thismap)).'</p>';
+
   return $output;
 }
 
@@ -196,7 +193,6 @@
  * @return
  * A gmap centred on the
  */
-
 function gmap_location_node_map($n,$thismap,$single=false){
   if ((isset($n->gmap_location_latitude) && isset($n->gmap_location_longitude)) || (isset($n->location['latitude']) && isset($n->location['longitude']))){
     $latitude = isset($n->gmap_location_latitude) ? $n->gmap_location_latitude : $n->location['latitude'];
@@ -255,11 +251,10 @@
 }
 
 /**
- * Implementation of hook_settings.
+ * Admin Settings Page
  *
  */
-
-function gmap_location_settings() {
+function gmap_location_admin_settings() {
 
   $markers=gmap_get_markers();
   
@@ -268,58 +263,57 @@
     '#title' => t('Geocode Locations'),
   );
   $form['geocoding']['gmap_geocode'] = array(
-    '#type'=>'radios',
-    '#title'=>t('Enable the Google Map API geocoding'),
-    '#default_value'=>variable_get('gmap_geocode', 1),
+    '#type' => 'radios',
+    '#title' => t('Enable the Google Map API geocoding'),
+    '#default_value' => variable_get('gmap_geocode', 1),
     '#options' => array(1=>'Enabled', 0=>'Disabled'),
   );
 
-
   $form['user'] = array(
     '#type' => 'fieldset', 
     '#title' => t('Location settings for users'),
   );
   $form['user']['gmap_user'] = array(
-    '#type'=>'checkbox',
-    '#title'=>t('Profile map'),
-    '#default_value'=>variable_get('gmap_user', true),
-    '#description'=>t('Let users set/edit their location in their profile.'),
+    '#type' => 'checkbox',
+    '#title' => t('Profile map'),
+    '#default_value' => variable_get('gmap_user', true),
+    '#description' => t('Let users set/edit their location in their profile.'),
   );
   $form['user']['gmap_user_profile_category'] = array(
-    '#type'=>'textfield',
-    '#title'=>t('Profile category title'),
-    '#default_value'=>variable_get('gmap_user_profile_category', "Location map"),
-    '#size'=>50,
-    '#maxlength'=>50,
-    '#description'=>t('Let users set/edit their location in their profile.'),
+    '#type' => 'textfield',
+    '#title' => t('Profile category title'),
+    '#default_value' => variable_get('gmap_user_profile_category', "Location map"),
+    '#size' => 50,
+    '#maxlength' => 50,
+    '#description' => t('Let users set/edit their location in their profile.'),
   );
   $form['user']['gmap_user_map'] = array(
-    '#type'=>'textfield',
-                                       '#title'=>t('Default user map'),
-                                       '#default_value'=>variable_get('gmap_user_map', '[gmap |id=usermap|center=40,0|zoom=3|width=100%|height=400px]'),
-                                       '#size'=>50,
-                                       '#maxlength'=>500,
-    '#description'=>t('The gmap macro where the user information will be diplayed on.'),
+    '#type' => 'textfield',
+    '#title' => t('Default user map'),
+    '#default_value' => variable_get('gmap_user_map', '[gmap |id=usermap|center=40,0|zoom=3|width=100%|height=400px]'),
+    '#size' => 50,
+    '#maxlength' => 500,
+    '#description' => t('The gmap macro where the user information will be diplayed on.'),
   );
   $form['user']['gmap_user_map_header'] = array(
-    '#type'=>'textarea',
-                                              '#title'=>t('Text at the top of the map/users page'),
-                                              '#default_value'=>variable_get('gmap_user_map_header', t('This map illustrates the extent of users of this website. Each marker indicates a user that has entered their locations.')),
-                                              '#cols'=>50,
-    '#rows'=>6 ,
+    '#type' => 'textarea',
+    '#title' => t('Text at the top of the map/users page'),
+    '#default_value' => variable_get('gmap_user_map_header', t('This map illustrates the extent of users of this website. Each marker indicates a user that has entered their locations.')),
+    '#cols' => 50,
+    '#rows' => 6,
   );
   $form['user']['gmap_user_map_marker'] = array(
-    '#type'=>'select',
-                                              '#title'=>t('Marker for users'),
-                                              '#default_value'=>variable_get('gmap_user_map_marker', 'drupal'),
-    '#options'=>$markers,
+    '#type' => 'select',
+    '#title' => t('Marker for users'),
+    '#default_value' => variable_get('gmap_user_map_marker', 'drupal'),
+    '#options' => $markers,
   );
 
   // Option to use a different marker for each role
   $form['user']['roles'] = array(
-    '#type'=>'fieldset',
-                               '#title'=>t('Markers per role'),
-    '#description'=>t('Use a different marker to denote users in the following roles.'),
+    '#type' => 'fieldset',
+    '#title' => t('Markers per role'),
+    '#description' => t('Use a different marker to denote users in the following roles.'),
   );
 
   // Retrieve and sort list of roles, sans anonymous user
@@ -329,10 +323,10 @@
   // Create a selection box per role
   foreach ($roles as $rid => $role) {
     $form['user']['roles']["gmap_role_map_marker_$rid"] = array(
-      '#type'=>'select',
-                                                              '#title'=>$role,
-                                                              '#default_value'=>variable_get("gmap_role_map_marker_$rid", variable_get('gmap_user_map_marker', 'drupal')),
-      '#options'=>$markers,
+      '#type' => 'select',
+      '#title' => $role,
+      '#default_value' => variable_get("gmap_role_map_marker_$rid", variable_get('gmap_user_map_marker', 'drupal')),
+      '#options' => $markers,
     );
   }
 
@@ -342,38 +336,38 @@
     '#title' => t('Location settings for nodes'),
   );
   $form['node']['gmap_node_map'] = array(
-    '#type'=>'textfield',
-                                       '#title'=>t('Default node map'),
-    '#default_value'=>variable_get('gmap_node_map', '[gmap |id=nodemap|center=40,0|zoom=3|width=100%|height=400px]'),
-                                       '#size'=>50,
-                                       '#maxlength'=>500,
-    '#description'=>t('The gmap macro where the user information will be diplayed on.'),
+    '#type' => 'textfield',
+    '#title' => t('Default node map'),
+    '#default_value' => variable_get('gmap_node_map', '[gmap |id=nodemap|center=40,0|zoom=3|width=100%|height=400px]'),
+    '#size' => 50,
+    '#maxlength' => 500,
+    '#description' => t('The gmap macro where the user information will be diplayed on.'),
   );
   $form['node']['gmap_node_map_header'] = array(
-    '#type'=>'textarea',
-                                              '#title'=>t('Text at the top of the map/nodes page'),
-                                              '#default_value'=>variable_get('gmap_node_map_header', t('This map illustrates the locations of the nodes on this website. Each marker indicates a node associated with a specific location.')),
-                                              '#cols'=>50,
-    '#rows'=>6 
+    '#type' => 'textarea',
+    '#title' => t('Text at the top of the map/nodes page'),
+    '#default_value' => variable_get('gmap_node_map_header', t('This map illustrates the locations of the nodes on this website. Each marker indicates a node associated with a specific location.')),
+    '#cols' => 50,
+    '#rows' => 6,
   );
 
   $ntypes=node_get_types();
   foreach ($ntypes as $key => $value) {
     if (variable_get('location_'. $key, 0)) {
       $form['node']['gmap_node_marker_'.$key]=array(
-        '#type'=>'select',
-                                                        '#title'=>t('Marker for '.$value),
-        '#default_value'=>variable_get('gmap_node_marker_'.$key, ''),
-        '#options'=>$markers,
+        '#type' => 'select',
+        '#title' => t('Marker for '.$value),
+        '#default_value' => variable_get('gmap_node_marker_'.$key, ''),
+        '#options' => $markers,
       );
     }
   }
   return $form;
 }
 
-/*
- * draw block of location for current node.
-*/
+/**
+ * Draw block of location for current node.
+ */
 function gmap_location_block($op = 'list', $delta = 0, $edit = array()) {
 
   // The $op parameter determines what piece of information is being requested.
@@ -513,7 +507,7 @@
 function gmap_location_author_block_view($nid) {
   $block=array();
 /*
-  $node = node_load(array('nid' => $nid));
+  $node = node_load($nid);
   if (variable_get('gmap_location_author_block_'.$node->type)) {
     $block['subject'] = t('Author Location');
     load_user(array($node->author))
@@ -578,7 +572,7 @@
 }
 
 function gmap_location_user($op, &$edit, &$user, $category = NULL) {
-  if (module_exist('gmap') && variable_get('gmap_user', 0) && user_access('set user location')) {
+  if (module_exists('gmap') && variable_get('gmap_user', 0) && user_access('set user location')) {
     $object->gmap_location_latitude = $edit['gmap_location_latitude'];
     $object->gmap_location_longitude = $edit['gmap_location_longitude'];
     $object->eid = $user->uid;
@@ -620,47 +614,46 @@
 
 function gmap_location_form_alter($form_id, &$form) {
 
-  if (module_exist('location')) {
+  if (module_exists('location')) {
     return;
   }
 
-  if(isset($form['type'])) {
-    $type = $form['type']['#value'];
-    switch ($form_id) {
-      case $type .'_node_settings':
-        $form['gmap'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Google Maps'),
-          '#weight' => 0,  //0 puts at the top, 1 puts it at the bottom below the submit??
-        );
-        $form['gmap']['gmap_node_'. $type] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Allow users to add Google Maps info to this node type'),
-          '#default_value' => variable_get('gmap_node_'. $type, 0),
-          '#description' => t('The location information will be available to the google maps module, and can be shown in a block.'),
-          '#required' => FALSE,
-        );
-        $form['gmap']['gmap_node_marker_'.$type] = array(
-          '#type' => 'select',
-          '#title' => t('Marker for this nodetype'),
-          '#default_value' => variable_get('gmap_node_marker_'.$type, variable_get('gmap_user_map_marker', 'drupal')),
-          '#options' => gmap_get_markers(),
-        );
-        break;
-      case $type .'_node_form':
-        if(variable_get('gmap_node_'. $type, 0)) {
-          $edit = array();
-          _gmap_location_map_form($form, $edit, 'node');
-        }
-        break;
+  if ($form_id == 'node_type_form') {
+    $type = $form['old_type']['#value'];
+    
+    $form['gmap'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Google Maps'),
+      '#weight' => 0,  //0 puts at the top, 1 puts it at the bottom below the submit??
+    );
+    $form['gmap']['gmap_node'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Allow users to add Google Maps info to this node type'),
+      '#default_value' => variable_get('gmap_node_'. $type, 0),
+      '#description' => t('The location information will be available to the google maps module, and can be shown in a block.'),
+      '#required' => FALSE,
+    );
+    $form['gmap']['gmap_node_marker'] = array(
+      '#type' => 'select',
+      '#title' => t('Marker for this nodetype'),
+      '#default_value' => variable_get('gmap_node_marker_'.$type, variable_get('gmap_user_map_marker', 'drupal')),
+      '#options' => gmap_get_markers(),
+    );
+  }
+  else {
+    if (isset($form['type']) && $form_id == $form['type'].'_node_form') {
+      echo "Flush!";
+      if(variable_get('gmap_node_'. $type, 0)) {
+        $edit = array();
+        _gmap_location_map_form($form, $edit, 'node');
+      }
     }
   }
 }
 
 /**
- *  implementation of hook_form()
+ * Implementation of hook_form()
  */
-
 function gmap_location_form(&$node, &$param) {
 
 }
@@ -702,6 +695,7 @@
 }
 
 function _gmap_location_map_form(&$form, &$edit, $type) {
+echo "BOO!";
   if($type=="user") {
     $latitude = $edit['gmap_location_latitude'];
     $longitude = $edit['gmap_location_longitude'];
@@ -719,8 +713,8 @@
     '#collapsed' => false,
   );
   $form['coordinates']['gmap_node']=array(
-    '#type'=>'markup',
-    '#value'=>'');
+    '#type'  => 'gmap',
+  );
   $form['coordinates']['gmap_location_latitude']=array(
     '#type'=>'textfield',
     '#id'=>'gmap-latitude',
Index: gmapmacro.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmapmacro.js,v
retrieving revision 1.4
diff -u -r1.4 gmapmacro.js
--- gmapmacro.js	16 Apr 2006 07:39:48 -0000	1.4
+++ gmapmacro.js	7 Jan 2007 03:22:14 -0000
@@ -4,18 +4,26 @@
 var mapdiv;
 var colors;
 
-if (isJsEnabled()) {
-  addLoadEvent(gmap_init);
+if (Drupal.jsEnabled) {
+//  $(document).ready(gmap_init).unload(gmap_uninit);
 }
 
 function gmap_args(args) {
   gmap_args = args;
 }
 
+function gmap_uninit() {
+  // uninit.
+  alert("Test");
+  GUnload();
+}
+
 function gmap_init() {
   if (!GBrowserIsCompatible()) { return; }
-  
-  mapdiv = $('map');
+
+  $('div#map').each(function() {
+     mapdiv = this;
+  });
   map = new GMap2(mapdiv);
   
   keyboardhandler=new GKeyboardHandler(map);
@@ -28,9 +36,9 @@
 
    // extend the map object
   map.drupal = new Object();
-  map.drupal.mapid=$('gmap-mapid').value
-  map.drupal.latLongStr = $('gmap-latlong').value;
-  map.drupal.currentControlType = 'Large';
+  map.drupal.mapid = $('#gmap-mapid').val();
+  map.drupal.latLongStr = $('#gmap-latlong').val();
+  map.drupal.currentControlType = 'Large'; // $('#gmap-maptype').val();
   map.drupal.currentControl = mycontrol;
   map.drupal.linecolors = colors;
   map.drupal.points = new Array();
@@ -38,29 +46,29 @@
   map.drupal.line1overlay=null;  map.drupal.line1points=new Array(); map.drupal.line1string=new String(); map.drupal.gmapline1=new String();
   map.drupal.line2overlay=null;  map.drupal.line2points=new Array(); map.drupal.line2string=new String(); map.drupal.gmapline2=new String();
   map.drupal.line3overlay=null;  map.drupal.line3points=new Array(); map.drupal.line3string=new String(); map.drupal.gmapline3=new String();
-  $('gmap-macrotext').value = map_to_macro(map);
+  $('#gmap-macrotext').val(map_to_macro(map));
   
   // Event listeners
   GEvent.addListener(map, "moveend", function() {
     var center = map.getCenter();
     map.drupal.latLongStr = center.lat() + ', ' + center.lng() ;
 
-    $('gmap-latlong').value = map.drupal.latLongStr;
-    $('gmap-macrotext').value = map_to_macro(map);
+    $('#gmap-latlong').val(map.drupal.latLongStr);
+    $('#gmap-macrotext').val(map_to_macro(map));
   });
   
   GEvent.addListener(map, "zoomend", function(previouszoom,newzoom) {
-    $('gmap-zoom').value = newzoom;
-    $('gmap-macrotext').value = map_to_macro(map);
+    $('#gmap-zoom').val(newzoom);
+    $('#gmap-macrotext').val(map_to_macro(map));
 
   });
   
   GEvent.addListener(map, "maptypechanged", function() {
     var maptype = map.getCurrentMapType();
-    if (maptype == G_NORMAL_MAP) $('gmap-maptype').value = "Map";
-    if (maptype == G_HYBRID_MAP) $('gmap-maptype').value = "Hybrid";
-    if (maptype == G_SATELLITE_MAP) $('gmap-maptype').value = "Satellite";
-    $('gmap-macrotext').value = map_to_macro(map);
+    if (maptype == G_NORMAL_MAP) $('#gmap-maptype').val("Map");
+    if (maptype == G_HYBRID_MAP) $('#gmap-maptype').val("Hybrid");
+    if (maptype == G_SATELLITE_MAP) $('#gmap-maptype').val("Satellite");
+    $('#gmap-macrotext').val(map_to_macro(map));
   });
 
   GEvent.addListener(map, 'click', function(overlay, point) {
@@ -82,7 +90,7 @@
       map.removeOverlay(overlay);
     }
     else if (point) {
-      var selected = $('gmap-clicktype').value;
+      var selected = $('#gmap-clicktype').val();
       switch (selected) {
         // I've got the feeling that some of the following logic could be trimmed
         case 'Points':
@@ -122,15 +130,15 @@
           break;
       }      
     }
-    $('gmap-macrotext').value = map_to_macro(map);
+    $('#gmap-macrotext').val(map_to_macro(map));
   });
   //initialize default values
-  set_gmap_latlong($('gmap-latlong').value);
-  map.setZoom(parseInt($('gmap-zoom').value));
-  set_gmap_type($('gmap-maptype').value);
-  set_control_type($('gmap-controltype').value);
-  set_gmap_dimension($('gmap-height'), 'height');
-  set_gmap_dimension($('gmap-width'), 'width');
+  set_gmap_latlong($('#gmap-latlong').val());
+  map.setZoom(parseInt($('#gmap-zoom').val()));
+  set_gmap_type($('#gmap-maptype').val());
+  set_control_type($('#gmap-controltype').val());
+  set_gmap_dimension($('#gmap-height').val(), 'height');
+  set_gmap_dimension($('#gmap-width').val(), 'width');
 }
 
 function gmap_set_line_colors(args) {
@@ -143,8 +151,8 @@
 function map_to_macro(gmap) {
   var zooml = ' |zoom=' + gmap.getZoom();
   var centerStr = ' |center=' + gmap.drupal.latLongStr;
-  var width = ' |width=' + $('gmap-width').value;
-  var height = ' |height=' + $('gmap-height').value;
+  var width = ' |width=' + $('#gmap-width').val();
+  var height = ' |height=' + $('#gmap-height').val();
   var id = ' |id=' + gmap.drupal.mapid;
   var control = ' |control=' + gmap.drupal.currentControlType;
   var type = ' |type=' + gmap.drupal.currentMapType;
@@ -169,7 +177,7 @@
 
 function set_gmap_mapid(instring) {
    map.drupal.mapid=instring;
-   $('gmap-macrotext').value=map_to_macro(map);
+   $('#gmap-macrotext').val(map_to_macro(map));
 }
 
 function set_gmap_latlong(instring) {
@@ -184,7 +192,7 @@
   }
   if (incontrol == "Small") map.addControl(map.drupal.currentControl = new GSmallMapControl());
   if (incontrol == "Large") map.addControl(map.drupal.currentControl = new GLargeMapControl());
-  $('gmap-macrotext').value = map_to_macro(map);
+  $('#gmap-macrotext').val(map_to_macro(map));
 }
 
 function set_gmap_type(intype) {
@@ -192,12 +200,12 @@
   if (intype == "Map") map.setMapType(G_NORMAL_MAP);
   if (intype == "Hybrid") map.setMapType(G_HYBRID_MAP);
   if (intype == "Satellite") map.setMapType(G_SATELLITE_MAP);
-  $('gmap-macrotext').value = map_to_macro(map);
+  $('#gmap-macrotext').val(map_to_macro(map));
 }
 
 function setgmapZoom(invalue) {
   map.setZoom(parseInt(invalue));
-  $('gmap-macrotext').value = map_to_macro(map);
+  $('#gmap-macrotext').val(map_to_macro(map));
 }
 
 function set_gmap_dimension(elem, dimension) {
@@ -214,8 +222,8 @@
     }
  //   gmap_init(map);
     map.checkResize();
-    $('gmap-macrotext').value = map_to_macro(map);
-    set_gmap_latlong($('gmap-latlong').value);
+    $('#gmap-macrotext').val(map_to_macro(map));
+    set_gmap_latlong($('#gmap-latlong').val());
   }
 }
 
@@ -234,7 +242,7 @@
 }
 
 function newid() {
-  var newvalue = $('gmap-id').value;
+  var newvalue = $('#gmap-mapid').val();
   newvalue=newvalue.match(/^[0-9A-Za-z_-]+/);
   if (newvalue.length==0) {
     newvalue='map';
--- /dev/null	2005-11-20 21:22:37.000000000 -0600
+++ gmap.info	2006-12-29 12:50:17.000000000 -0600
@@ -0,0 +1,4 @@
+; $Id$
+name = GMap
+description = Filter to allow insertion of a google map into a node
+version = "$Name$"
--- /dev/null	2005-11-20 21:22:37.000000000 -0600
+++ gmap_location.info	2006-12-29 12:51:00.000000000 -0600
@@ -0,0 +1,6 @@
+; $Id$
+name = GMap Location
+description = Display location.module information on Google Maps
+version = "$Name$"
+dependencies = gmap location
+
--- /dev/null	2005-11-20 21:22:37.000000000 -0600
+++ gmap.install	2007-01-03 10:42:04.000000000 -0600
@@ -0,0 +1,34 @@
+<?php
+
+
+
+/**
+ * Convert defaults to new format.
+ */
+function gmap_update_1() {
+  // Load our old defaults into an array.
+  $gmap_default = array(
+    'width' => variable_get('gmap_default_width', '300px'),
+    'height' => variable_get('gmap_default_height', '200px'),
+    'zoom' => variable_get('gmap_default_zoom', 3),
+    'control' => variable_get('gmap_default_control', 'Small'),
+    'latlong' => variable_get('gmap_default_latlong', '40,0'),
+    'type' => variable_get('gmap_default_type', 'Map'),
+    'line1_color' => variable_get('gmap_default_line1_color', '#00cc00'),
+    'line2_color' => variable_get('gmap_default_line2_color', '#ff0000'),
+    'line3_color' => variable_get('gmap_default_line3_color', '#0000ff'),
+  );
+  // Set the new defaults from it.
+  variable_set('gmap_default',$gmap_default);
+  // Clean up the now unneeded variables.
+  variable_del('gmap_default_width');
+  variable_del('gmap_default_height');
+  variable_del('gmap_default_zoom');
+  variable_del('gmap_default_control');
+  variable_del('gmap_default_latlong');
+  variable_del('gmap_default_type');
+  variable_del('gmap_default_line1_color');
+  variable_del('gmap_default_line2_color');
+  variable_del('gmap_default_line3_color');
+}
+
