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 02:56:59 -0000
@@ -72,25 +72,40 @@ 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);
       }
       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_settings', array(
+            'autoLoad'    => TRUE,  // Automatically use the chunk marker loader if there are lots of markers?
+            'threshold'   => 20,    // How many is 'lots'?
+            'chunkSize'   => 1,     // How many markers per chunk.
+            'chunkDelay'  => 200,  // 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 +145,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.  Processing lots of markers can cause the browser to freeze and appear to have crashed while it processes the markers and adds them to the DOM.  The chunk marker loader is used anyway if the Chunk Autoload Threshold is reached and Chunk Autoload is on (which are the default settings).'),
+        ),
         'overview' => array(
           'title' => t('Enable Overview Map'),
           'default' => FALSE,
@@ -162,21 +184,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 +986,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 +1018,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);
 }
 
