Index: gmap_location.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap_location.module,v
retrieving revision 1.58
diff -u -p -r1.58 gmap_location.module
--- gmap_location.module	13 Mar 2009 17:10:45 -0000	1.58
+++ gmap_location.module	4 Nov 2010 13:28:19 -0000
@@ -269,6 +269,24 @@ function gmap_location_node_page($nid = 
     ". $add_sql), $nid);
 
   $count = 0;
+
+  $multi_locs = array();
+  // Spacing in the X and Y direction for each new marker.
+  $offset = .00003;
+  // Current duplicate value of lat/long combination - 1.
+  $cur_val = 0;
+  // Number of steps from origin to current "square" wall being built.
+  $mag_val = 0;
+  // Number of steps from start position of current "square" wall being built.
+  // In northern hemisphere, this starts at the upper right; southern hemisphere, lower right ... I think that's right :)
+  $step_val = 0;
+  // mag_val * 2.
+  $num_steps = 0;
+  // 0, 1, 2, or 3 - represents current direction of the square being built (see cases below).
+  $dir_val = 0;
+  // Current position value along a "square" wall being built, resets to zero when dir_val changes (new segment of square being built).
+  $pos_val = 0;
+
   while ($row = db_fetch_object($result)) {
     $count++;
     $newmarker = array();
@@ -283,6 +301,65 @@ function gmap_location_node_page($nid = 
 
     $newmarker['latitude'] = $row->latitude;
     $newmarker['longitude'] = $row->longitude;
+
+    // Keep a count of all markery by lon/lat so we can see if there are
+    // multiple markers at any points.
+    $multi_locs[$newmarker['latitude']][$newmarker['longitude']] += 1;
+
+    if ($multi_locs[$newmarker['latitude']][$newmarker['longitude']] > 1) {
+      $cur_val = $multi_locs[$newmarker['latitude']][$newmarker['longitude']] - 1;
+      $mag_val = (int) ((sqrt($cur_val) + 1) / 2);
+      $step_val = $cur_val - pow(2 * $mag_val - 1, 2);
+      $num_steps = 2 * $mag_val;
+      $dir_val = (int) ($step_val / $num_steps);
+      $pos_val = $step_val % $num_steps;
+
+      switch ($dir_val) {
+        // Top to bottom.
+        //       x
+        // x x x |
+        // x x x |
+        // x x x |
+        case 0:
+          $newmarker['longitude'] += ($mag_val * $offset);
+          $newmarker['latitude'] += $offset * ($mag_val - $pos_val);
+          break;
+
+        // Right to left.
+        //       x
+        // x x x x
+        // x x x x
+        // x x x x
+        // - - - x
+        case 1:
+          $newmarker['latitude'] -= ($mag_val * $offset);
+          $newmarker['longitude'] += $offset * ($mag_val - $pos_val);
+          break;
+
+        // Bottom to top.
+        //         x
+        // | x x x x
+        // | x x x x
+        // | x x x x
+        // x x x x x
+        case 2:
+          $newmarker['longitude'] -= ($mag_val * $offset);
+          $newmarker['latitude'] += $offset * ($pos_val - $mag_val);
+          break;
+
+        // Left to right.
+        // x - - - x
+        // x x x x x
+        // x x x x x
+        // x x x x x
+        // x x x x x
+        case 3:
+          $newmarker['latitude'] += ($mag_val * $offset);
+          $newmarker['longitude'] += $offset * ($pos_val - $mag_val);
+          break;
+      }
+    }
+
     $newmarker['markername'] = isset($markertypes[$row->type]) ? $markertypes[$row->type] : 'drupal';
     if (isset($row->marker) && !empty($row->marker)) {
       $newmarker['markername'] = $row->marker;
Index: gmap_plugin_style_gmap.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap_plugin_style_gmap.inc,v
retrieving revision 1.11.2.5
diff -u -p -r1.11.2.5 gmap_plugin_style_gmap.inc
--- gmap_plugin_style_gmap.inc	30 Sep 2010 09:51:05 -0000	1.11.2.5
+++ gmap_plugin_style_gmap.inc	4 Nov 2010 13:28:19 -0000
@@ -124,6 +124,24 @@ class gmap_plugin_style_gmap extends vie
     // Render each group separately and concatenate.  Plugins may override this
     // method if they wish some other way of handling grouping.
     $output = '';
+
+    $multi_locs = array();
+    // Spacing in the X and Y direction for each new marker.
+    $offset = .00003;
+    // Current duplicate value of lat/long combination - 1.
+    $cur_val = 0;
+    // Number of steps from origin to current "square" wall being built.
+    $mag_val = 0;
+    // Number of steps from start position of current "square" wall being built.
+    // In northern hemisphere, this starts at the upper right; southern hemisphere, lower right ... I think that's right :)
+    $step_val = 0;
+    // mag_val * 2.
+    $num_steps = 0;
+    // 0, 1, 2, or 3 - represents current direction of the square being built (see cases below).
+    $dir_val = 0;
+    // Current position value along a "square" wall being built, resets to zero when dir_val changes (new segment of square being built).
+    $pos_val = 0;
+
     foreach ($sets as $title => $records) {
       $markers = array();
       $offsets = array();
@@ -190,6 +208,64 @@ class gmap_plugin_style_gmap extends vie
             $tooltip = $row->$tooltip_field;
           }
 
+          // Keep a count of all markery by lon/lat so we can see if there are
+          // multiple markers at any points.
+          $multi_locs[$row->gmap_lat][$row->gmap_lon] += 1;
+
+          if ($multi_locs[$row->gmap_lat][$row->gmap_lon] > 1) {
+            $cur_val = $multi_locs[$row->gmap_lat][$row->gmap_lon] - 1;
+            $mag_val = (int) ((sqrt($cur_val) + 1) / 2);
+            $step_val = $cur_val - pow(2 * $mag_val - 1, 2);
+            $num_steps = 2 * $mag_val;
+            $dir_val = (int) ($step_val / $num_steps);
+            $pos_val = $step_val % $num_steps;
+
+            switch ($dir_val) {
+              // Top to bottom.
+              //       x
+              // x x x |
+              // x x x |
+              // x x x |
+              case 0:
+                $lon += ($mag_val * $offset);
+                $lat += $offset * ($mag_val - $pos_val);
+                break;
+
+              // Right to left.
+              //       x
+              // x x x x
+              // x x x x
+              // x x x x
+              // - - - x
+              case 1:
+                $lat -= ($mag_val * $offset);
+                $lon += $offset * ($mag_val - $pos_val);
+                break;
+
+              // Bottom to top.
+              //         x
+              // | x x x x
+              // | x x x x
+              // | x x x x
+              // x x x x x
+              case 2:
+                $lon -= ($mag_val * $offset);
+                $lat += $offset * ($pos_val - $mag_val);
+                break;
+
+              //Left to right
+              // x - - - x
+              // x x x x x
+              // x x x x x
+              // x x x x x
+              // x x x x x
+              case 3:
+                $lat += ($mag_val * $offset);
+                $lon += $offset * ($pos_val - $mag_val);
+                break;
+            }
+          }
+
           $marker = array(
             'latitude' => $lat,
             'longitude' => $lon,
