### Eclipse Workspace Patch 1.0
#P DrupalCVS Gmap
Index: gmap_plugin_style_gmap.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap_plugin_style_gmap.inc,v
retrieving revision 1.9
diff -u -r1.9 gmap_plugin_style_gmap.inc
--- gmap_plugin_style_gmap.inc	3 Apr 2009 15:34:50 -0000	1.9
+++ gmap_plugin_style_gmap.inc	3 Sep 2009 13:01:41 -0000
@@ -29,6 +29,8 @@
     $options['markers'] = array('default' => 'static');
     $options['markertype'] = array('default' => 'drupal');
 
+    $options['center_on_nodearg'] = array('default' => '0');
+
     $options['latfield'] = array('default' => '');
     $options['lonfield'] = array('default' => '');
     $options['markerfield'] = array('default' => '');
@@ -97,9 +99,25 @@
     foreach ($sets as $title => $records) {
       $markers = array();
       $offsets = array();
+      $lat_center = null;
+      $lon_center = null;
+      $nid_center = null;
+
+      // we search nid argument used to center map
+      if ($this->options['center_on_nodearg'] && $nodehandler = $this->view->display_handler->get_handler('argument', 'null')) {
+        $nid_center = $nodehandler->get_value();
+      }
+
         foreach ($records as $label => $row) {
         $lat = (float)$row->{$lat_field};
         $lon = (float)$row->{$lon_field};
+
+        // if this row will be used as center map then we keep its lon/lat 
+        if (!empty($nid_center) && $nid_center == $row->nid) {
+          $lon_center = $lon;
+          $lat_center = $lat;
+        }
+
         if (!empty($lat) && !empty($lon)) {
           if ($this->options['markers'] == 'nodetype') {
             if (isset($markertypes[$row->gmap_node_type])) {
@@ -139,6 +157,13 @@
       }
       if (!empty($markers)) { // Don't draw empty maps.
         $map = gmap_parse_macro($this->options['macro']);
+
+        // if center lon/lat are not empty they are used to center map 
+        if (!empty($lon_center) && !empty($lat_center)) {
+          $map['longitude'] = $lon_center;
+          $map['latitude'] = $lat_center;
+        }
+
         $map['markers'] = $markers;
         $output .= theme($this->theme_functions(), $this->view, $this->options, $map, $title);
       }
@@ -151,6 +176,13 @@
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
+    $form['center_on_nodearg'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Center on node argument'),
+      '#default_value' => $this->options['center_on_nodearg'],
+      '#description' => t('Note: The view must contain a node by node id as an argument Global:Null'),
+    );
+
     $form['macro'] = array(
       '#type' => 'textfield',
       '#title' => t('Macro'),
