Index: js/locpick.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/js/Attic/locpick.js,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 locpick.js
--- js/locpick.js	12 Mar 2007 23:12:57 -0000	1.1.2.3
+++ js/locpick.js	25 Mar 2008 11:45:14 -0000
@@ -9,7 +9,7 @@ Drupal.gmap.addHandler('gmap',function(e
 
   var binding = obj.bind("locpickchange", function() {
     if (obj.locpick_coord) {
-      GEvent.trigger(obj.map,"click",null,obj.locpick_coord);
+      GEvent.trigger(obj.map,"dblclick", null, obj.locpick_coord);
     }
   });
 
@@ -22,8 +22,14 @@ Drupal.gmap.addHandler('gmap',function(e
   obj.bind("init", function() {
     if (obj.vars.behavior.locpick) {
       obj.locpick_coord = new GLatLng(obj.vars.latitude, obj.vars.longitude);
-
-      GEvent.addListener(obj.map, "click", function(overlay,point) {
+      // Don't allow GMap2 to zoom on double click.  That breaks the following listener.
+      obj.map.disableDoubleClickZoom();
+      var singleClickCount = 0;
+      var doubleClicked = false;
+
+      GEvent.addListener(obj.map, "dblclick", function(overlay,point) {
+        // Don't warn about single clicks, it's a double click.
+        doubleClicked = true;
         obj.map.checkResize();
         if (!overlay) {
           if (obj.locpick_point) {
@@ -36,9 +42,23 @@ Drupal.gmap.addHandler('gmap',function(e
           obj.map.panTo(point);
           obj.change('locpickchange', binding);
         }
-        else {
+      });
+      
+      GEvent.addListener(obj.map, "click", function(overlay) {
+        if (overlay) {
           // Unsetting the location
-          obj.change('locpickremove',-1);
+          obj.change('locpickremove', -1);
+        }
+        else {
+          // This could be a double or a single click.  Assume it's a single unless proven otherwise.
+          doubleClicked = false;
+          setTimeout(function() {
+            // It's a popup alertbox, which is rather annoying.  So don't show it more than twice.
+            if (!doubleClicked && singleClickCount++ < 2) {
+              // It's definately a single click. Tell the user they need to double click.
+              alert(Drupal.settings.locpickSingleClickMessage);
+            }
+          }, 500); 
         }
       });
     }
Index: gmap.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/Attic/gmap.module,v
retrieving revision 1.51.2.108
diff -u -p -r1.51.2.108 gmap.module
--- gmap.module	18 Mar 2008 22:54:32 -0000	1.51.2.108
+++ gmap.module	25 Mar 2008 11:45:15 -0000
@@ -27,6 +27,11 @@ define('GMAP_WMS', variable_get('gmap_wm
 // for details on using other version numbers.
 define('GMAP_API_VERSION', '2.s');
 
+// Chunk markerloader defaults
+define('GMAP_CHUNK_THRESHOLD', 20);
+define('GMAP_CHUNK_SIZE', 1);
+define('GMAP_CHUNK_DELAY', 200);
+
 
 /**
  * Get the defaults for a gmap.
@@ -35,10 +40,10 @@ function gmap_defaults() {
   $defaults = array(
     'width' => '300px',
     'height' => '200px',
-    'zoom' => 3,
+    'zoom' => 1,
     'controltype' => 'Small',
     'align' => 'None',
-    'latlong' => '40,0',
+    'latlong' => '30,-100',
     'maptype' => 'Map',
     'line_colors' => array('#00cc00', '#ff0000', '#0000ff'),
   );
@@ -72,25 +77,42 @@ function gmap_gmap($op, $map=null) {
       $path = drupal_get_path('module', 'gmap') .'/js/';
       // Activate markers if needed
       if ($map['behavior']['dynmarkers'] || !empty($map['markers'])) {
-        drupal_add_js($path .'icon.js');
-        drupal_add_js($path .'marker.js');
-        drupal_add_js($path . variable_get('gmap_mm_type', 'gmap') .'_marker.js');
+        drupal_add_js($path .'icon.js', 'module', 'header', null, null, false);
+        drupal_add_js($path .'marker.js', 'module', 'header', null, null, false);
+        drupal_add_js($path . variable_get('gmap_mm_type', 'gmap') .'_marker.js', 'module', 'header', null, null, false);
       }
       if ($map['behavior']['locpick']) {
-        drupal_add_js($path .'locpick.js');
+        drupal_add_js($path .'locpick.js', 'module', 'header', null, null, false);
+        // Client-side UI strings need to be translatable too.
+        drupal_add_js(array('locpickSingleClickMessage' => t('Double click the map to set the location.  Single click the marker to delete.')), 'setting');
       }
       if (variable_get('gmap_load_zoom_plugin', TRUE) && !$map['behavior']['nomousezoom']) {
-        drupal_add_js(drupal_get_path('module', 'gmap') .'/thirdparty/mousewheel.js');
+        drupal_add_js(drupal_get_path('module', 'gmap') .'/thirdparty/mousewheel.js', 'module', 'header', null, null, false);
       }
-      if ($map['markers'] || $map['lines']) {
-        drupal_add_js($path .'markerloader_static.js');
+      if ($map['lines'] || $map['markers']) {
+        // Get the chunk markerloader settings.
+        $chunk_settings = variable_get('gmap_chunk_markerloader', array(
+            'autoLoad'    => TRUE,                  // Automatically use the chunk marker loader if there are lots of markers?
+            'threshold'   => GMAP_CHUNK_THRESHOLD,  // How many is 'lots'?
+            'chunkSize'   => GMAP_CHUNK_SIZE,       // How many markers per chunk.
+            'chunkDelay'  => GMAP_CHUNK_DELAY,      // Delay between each chunk in miliseconds.
+          ));
+        // Should we load markers in chunks?
+        if ($map['behavior']['chunkmarkerloader'] || ($chunk_settings['autoLoad'] && (count($map['markers']) > $chunk_settings['threshold']))) {
+          // loadChunkMarkers() in js/markerloader_chunks.js needs these settings too.
+          drupal_add_js(array('loadChunkMarkers' => $chunk_settings), 'setting');
+          drupal_add_js($path .'markerloader_chunks.js', 'module', 'header', null, null, false);
+        }
+        else {
+          drupal_add_js($path .'markerloader_static.js', 'module', 'header', null, null, false);
+        }
       }
       if ($map['shapes']) {
-        drupal_add_js($path .'shapeloader_static.js');
-        drupal_add_js($path .'gmap_shapes.js');
+        drupal_add_js($path .'shapeloader_static.js', 'module', 'header', null, null, false);
+        drupal_add_js($path .'gmap_shapes.js', 'module', 'header', null, null, false);
       }
       if (is_array($map['feed'])) {
-        drupal_add_js($path .'markerloader_georss.js');
+        drupal_add_js($path .'markerloader_georss.js', 'module', 'header', null, null, false);
       }
       break;
     case 'macro_multiple':
@@ -128,6 +150,11 @@ function gmap_gmap($op, $map=null) {
           'default' => FALSE,
           'help' => t('Load the marker loader system even if no markers to load are detected. Useful if you are injecting markers from somewhere else.'),
         ),
+        'chunkmarkerloader' => array(
+          'title' => t('Unconditionally load markers in chunks'),
+          'default' => FALSE,
+          'help' => t('Load markers in chunks, even if there are few markers. It is a good idea to load markers in chunks if you have lots of markers.  See the Chunk Markerloader settings for details and autoload settings.'),
+        ),
         'overview' => array(
           'title' => t('Enable Overview Map'),
           'default' => FALSE,
@@ -162,21 +189,21 @@ function _gmap_doheader() {
   }
   $gmap_path = drupal_get_path('module', 'gmap');
   drupal_add_css($gmap_path .'/gmap.css');
-  drupal_add_js($gmap_path .'/js/gmap.js');
+  drupal_add_js($gmap_path .'/js/gmap.js', 'module', 'header', null, null, false);
   $mm = variable_get('gmap_mm_type', 'gmap');
   if ($mm=='clusterer') {
-    drupal_add_js($gmap_path .'/js/icon.js');
-    drupal_add_js($gmap_path .'/thirdparty/Clusterer2.js');
+    drupal_add_js($gmap_path .'/js/icon.js', 'module', 'header', null, null, false);
+    drupal_add_js($gmap_path .'/thirdparty/Clusterer2.js', 'module', 'header', null, null, false);
   }
-  drupal_add_js($gmap_path .'/js/marker.js');
-  drupal_add_js($gmap_path .'/js/'. $mm .'_marker.js');
+  drupal_add_js($gmap_path .'/js/marker.js', 'module', 'header', null, null, false);
+  drupal_add_js($gmap_path .'/js/'. $mm .'_marker.js', 'module', 'header', null, null, false);
   $mms = variable_get('gmap_markermanager', array());
   if (empty($mms[$mm])) {
     $mms[$mm] = array();
   }
+
   drupal_add_js(array('gmap_markermanager' => $mms[$mm]), 'setting');
-// @@@
-drupal_add_js($gmap_path .'/js/poly.js');
+  drupal_add_js($gmap_path .'/js/poly.js', 'module', 'header', null, null, false);
   $key = variable_get('googlemap_api_key', '');
   if (module_exists('keys_api')) {
     $key = keys_api_get_key('gmap', $_SERVER['HTTP_HOST']);
@@ -964,9 +991,9 @@ function process_gmap_markerchooser($ele
 
 function theme_gmap_overlay_edit($element) {
   $path = drupal_get_path('module', 'gmap');
-  drupal_add_js($path .'/js/gmap.js');
-  drupal_add_js($path .'/js/gmap_shapes.js');
-  drupal_add_js($path .'/js/overlay_edit.js');
+  drupal_add_js($path .'/js/gmap.js', 'module', 'header', null, null, false);
+  drupal_add_js($path .'/js/gmap_shapes.js', 'module', 'header', null, null, false);
+  drupal_add_js($path .'/js/overlay_edit.js', 'module', 'header', null, null, false);
   return theme('select', $element);
 }
 
@@ -996,19 +1023,18 @@ function theme_gmap_coord($element) {
 }
 
 function theme_gmap_macrotext($element) {
-  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/macro.js');
-  // @@@
-  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/macrobuilder.js');
+  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/macro.js', 'module', 'header', null, null, false);
+  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/macrobuilder.js', 'module', 'header', null, null, false);
   return theme('textarea', $element);
 }
 
 function theme_gmap_address($element) {
-  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/address.js');
+  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/address.js', 'module', 'header', null, null, false);
   return theme('textfield', $element);
 }
 
 function theme_gmap_align($element) {
-  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/align.js');
+  drupal_add_js(drupal_get_path('module', 'gmap') .'/js/align.js', 'module', 'header', null, null, false);
   return theme('select', $element);
 }
 
Index: gmap_location.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/Attic/gmap_location.module,v
retrieving revision 1.26.2.55
diff -u -p -r1.26.2.55 gmap_location.module
--- gmap_location.module	6 Mar 2008 20:17:46 -0000	1.26.2.55
+++ gmap_location.module	25 Mar 2008 11:45:15 -0000
@@ -800,7 +800,7 @@ function gmap_location_user($op, &$edit,
   if (variable_get('gmap_user', 0) && user_access('set user location')) {
     switch ($op) {
       case 'load':
-        $result = db_query("SELECT latitude,longitude FROM {location} WHERE eid = %d AND type='user'", $user->uid);
+        $result = db_query("SELECT latitude,longitude FROM {location} WHERE eid = %d AND type='user' AND latitude IS NOT NULL", $user->uid);
         $u = db_fetch_object($result);
         if ($u) {
           $user->gmap_location_longitude = $u->longitude;
@@ -821,20 +821,23 @@ function gmap_location_user($op, &$edit,
       case 'update':
         if ($category == 'gmap_user') {
           // source==1, location.module's LOCATION_LATLON_USER_SUBMITTED define.
+          $lid = db_next_id('{location}_lid');
+          $lat = gmap_decimal($edit['gmap_location_latitude']);
+          $lon = gmap_decimal($edit['gmap_location_longitude']);
+
+          // If the user is removing their location data, we need to do that in the DB too.
+          if ($lat == 0 && $lon == 0) {
+            $lat = $lon = 'NULL';
+          }
+
           // Insert or update based on the existance of $user->gmap_location_set.
           if ($user->gmap_location_set) {
-            db_query("UPDATE {location} SET latitude = %s , longitude = %s , source = 1 WHERE eid = %d AND type = 'user'",
-              gmap_decimal($edit['gmap_location_latitude']),
-              gmap_decimal($edit['gmap_location_longitude']),
-              $user->uid);
+            db_query("UPDATE {location} SET latitude = %s , longitude = %s , source = 1 WHERE eid = %d AND type = 'user'", $lat, $lon, $user->uid);
           }
           else {
-            $lid = db_next_id('{location}_lid');
-            db_query("INSERT INTO {location} (eid, lid, type, latitude, longitude, source) VALUES (%d, %d, 'user', %s, %s, 1)",
-              $user->uid, $lid,
-              gmap_decimal($edit['gmap_location_latitude']),
-              gmap_decimal($edit['gmap_location_longitude']));
+            db_query("INSERT INTO {location} (eid, lid, type, latitude, longitude, source) VALUES (%d, %d, 'user', %s, %s, 1)", $user->uid, $lid, $lat, $lon);
           }
+
           unset($edit['gmap_location_latitude']);
           unset($edit['gmap_location_longitude']);
         }
@@ -842,14 +845,20 @@ function gmap_location_user($op, &$edit,
 
       case 'form':
         if ($category == 'gmap_user' && user_access('set user location')) {
+          // Use CSS to hide lat-lon text fields when js is enabled
+          drupal_add_css(drupal_get_path('module', 'gmap') . '/gmap_location.css');
+
+          // Create a form for user location picker.
           $form = array();
 
           $form['coordinates'] = array(
             '#type' => 'fieldset',
             '#title' => t('Coordinates'),
+            '#attributes' => array('class' => 'gmap-location-picker'),
             '#weight' => 5,
             '#collapsible' => $type!='user',
             '#collapsed' => false,
+            '#description' => t('Double click the map to set the location.  Single click the marker to delete.'),
           );
 
           // Reserve spot for map.
@@ -869,15 +878,13 @@ function gmap_location_user($op, &$edit,
             '#default_value' => $edit['gmap_location_longitude'],
             '#size' => 30,
             '#maxlength' => 120,
-            '#description' => t('The latitude and longitude will be entered here when you click on a location in the interactive map above. You can also fill in the values manually.'),
           );
 
           // @@@ Why is this based off the user map?
           $tmp = variable_get('gmap_user_map', _gmap_location_user_map_defaults());
-
           $form['coordinates']['gmap_node']['#value'] = gmap_set_location($tmp['macro'], $form['coordinates'], array('latitude' => 'gmap_location_latitude', 'longitude' => 'gmap_location_longitude'));
 
-/*
+          /*
           if (variable_get('gmap_geocode', 1)) {
             $form['coordinates']['gmap_location_address'] = array(
               '#type' => 'textfield',
@@ -885,7 +892,7 @@ function gmap_location_user($op, &$edit,
               '#description' => t('The address to be found on the map.  Enter an address and then hit "TAB" and the current location will be updated.  Please note that this address is not saved for the node, it is only used for finding a location.'),
             );
           }
-*/
+          */
         }
         return $form;
     }
