? gmap-5.patch
? gmap.info
? gmap_location.info
Index: gmap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap.module,v
retrieving revision 1.50
diff -u -r1.50 gmap.module
--- gmap.module	19 Nov 2006 07:46:14 -0000	1.50
+++ gmap.module	27 Nov 2006 02:41:24 -0000
@@ -28,25 +28,12 @@
 define('GMAP_CLUSTER', variable_get('gmap_cluster',0));
 define('GMAP_WMS', variable_get('gmap_wms',0));
 
-define('GMAP_API_V', '2.55a');
-
-/**
- * Implementation of hook_help.
- *
- */
-
-function gmap_help($section) {
-  switch ($section) {
-    case 'admin/modules#description':
-      return t('Filter to allow insertion of a google map into a node');
-  }
-}
+define('GMAP_API_V', '2.66');
 
 /**
  * Implementation of hook_perm.
  *
  */
-
 function gmap_perm() {
   return array('create macro');
 }
@@ -810,8 +797,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.css','module');
   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);
@@ -940,9 +926,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,7 +950,7 @@
   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
 
@@ -1131,17 +1126,17 @@
                                            '#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');
 }
 
 function gmap_macro_form() {
-        $form['macroform'] = array(
+    $form['macroform'] = array(
     '#type' => 'fieldset',
     '#title' => t('Gmap macro creation'),
     '#theme' => 'gmap_macro',
@@ -1151,9 +1146,14 @@
     '#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),
-  );
+//  $form['macroform']['javascript'] = array(
+//    '#value' => drupal_add_js('gmap_set_line_colors("'.implode('","',$linecolors).'")','inline'),
+//  );
+
+// Todo: Change this to a setting.
+drupal_add_js('gmap_set_line_colors("'.implode('","',$linecolors).'")','inline');
+
+
   $form['macroform']['mapid'] = array(
     '#type' => 'textfield',
     '#id' => 'gmap-mapid',
@@ -1234,7 +1234,7 @@
     '#id' => 'gmap-macrotext',
     '#title' => t('Macro text'),
   );
-  return drupal_get_form('macroform', $form);
+  return $form;
 }
 
 /**
Index: gmap_location.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap_location.module,v
retrieving revision 1.25
diff -u -r1.25 gmap_location.module
--- gmap_location.module	19 Nov 2006 07:47:18 -0000	1.25
+++ gmap_location.module	27 Nov 2006 02:41:24 -0000
@@ -10,31 +10,17 @@
  */
 
 /**
- * Implementation of hook_help.
+ * Implementation of hook_perm().
  *
  */
-
-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.
- *
- */
-
 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();
 
@@ -61,7 +47,6 @@
  * Draws a page with a google map that has all of the site users.
  *
  */
-
 function gmap_location_user_page() {
   global $user;
   $locationbyuser=array();
@@ -145,8 +130,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)) {
@@ -196,7 +179,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 +237,10 @@
 }
 
 /**
- * Implementation of hook_settings.
+ * Admin Settings Page
  *
  */
-
-function gmap_location_settings() {
+function gmap_location_admin_settings() {
 
   $markers=gmap_get_markers();
   
@@ -371,9 +352,9 @@
   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.
@@ -620,47 +601,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) {
 
 }
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	27 Nov 2006 02:41:25 -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-11-26 15:51:39.000000000 -0600
@@ -0,0 +1,3 @@
+; $Id$
+name = GMap
+description = Filter to allow insertion of a google map into a node
--- /dev/null	2005-11-20 21:22:37.000000000 -0600
+++ gmap_location.info	2006-11-26 16:13:43.000000000 -0600
@@ -0,0 +1,4 @@
+; $Id$
+name = GMap Location
+description = Display location.module information on Google Maps
+dependencies = gmap
