--- sites/all/modules/gmap/gmap_plugin_style_gmap.inc	2009-01-26 09:28:54.774519000 -0800
+++ sites/all/modules/gmap/gmap_plugin_style_gmapNew.inc	2009-01-26 09:28:55.213964000 -0800
@@ -1,5 +1,5 @@
 <?php
-// $Id$
+// $Id: gmap_plugin_style_gmap.inc,v 1.3 2008/11/24 22:47:12 bdragon Exp $
 
 /**
  * @file
@@ -29,18 +29,13 @@ class gmap_plugin_style_gmap extends vie
     $options['markers'] = array('default' => 'static');
     $options['markertype'] = array('default' => 'drupal');
 
-    $options['latfield'] = array('default' => '');
-    $options['lonfield'] = array('default' => '');
-    $options['markerfield'] = array('default' => '');
-
     return $options;
   }
 
   function query() {
     if ($this->options['datasource'] == 'location') {
-      $table = $this->view->query->ensure_table('location');
-      $this->view->query->add_field($table, 'latitude', 'gmap_lat');
-      $this->view->query->add_field($table, 'longitude', 'gmap_lon');
+      $this->view->query->add_field('location', 'latitude', 'gmap_lat');
+      $this->view->query->add_field('location', 'longitude', 'gmap_lon');
     }
 
     if ($this->options['markers'] == 'nodetype') {
@@ -56,20 +51,8 @@ class gmap_plugin_style_gmap extends vie
       vpr('gmap_plugin_style_gmap: Missing row plugin');
       return;
     }
-
-    $lat_field = 'gmap_lat';
-    $lon_field = 'gmap_lon';
-
-    // Determine fieldname for latitude and longitude fields.
-    if ($this->options['datasource'] == 'fields') {
-      $lat_field = $this->view->display_handler->get_handler('field', $this->options['latfield'])->field_alias;
-      $lon_field = $this->view->display_handler->get_handler('field', $this->options['lonfield'])->field_alias;
-    }
-
-    // Determine fieldname for marker field.
-    if ($this->options['markers'] == 'field') {
-      $marker_field = $this->view->display_handler->get_handler('field', $this->options['markerfield'])->field_alias;
-    }
+    
+    $defaults = gmap_defaults();
 
     $markername = isset($this->options['markertype']) ? $this->options['markertype'] : 'drupal';
 
@@ -88,8 +71,8 @@ class gmap_plugin_style_gmap extends vie
       $markers = array();
       $offsets = array();
         foreach ($records as $label => $row) {
-        $lat = (float)$row->{$lat_field};
-        $lon = (float)$row->{$lon_field};
+        $lat = (float)$row->gmap_lat;
+        $lon = (float)$row->gmap_lon;
         if (!empty($lat) && !empty($lon)) {
           if ($this->options['markers'] == 'nodetype') {
             if (isset($markertypes[$row->gmap_node_type])) {
@@ -101,27 +84,34 @@ class gmap_plugin_style_gmap extends vie
               $markername = $row->gmap_node_marker;
             }
           }
-          else if ($this->options['markers'] == 'field') {
-            if (!empty($row->{$marker_field})) {
-              $markername = $row->{$marker_field};
-            }
-          }
           if (!isset($offsets[$markername])) {
             $offsets[$markername] = 0;
           }
-          $markers[] = array(
+          $marker = array(
             'latitude' => $lat,
             'longitude' => $lon,
             'markername' => $markername,
             'offset' => $offsets[$markername],
-            'text' => $this->row_plugin->render($row),
           );
+          
+          // Set marker's title so that it will be displayed as tooltip for this marker
+          $node = node_load($row->nid);
+          $marker['opts']['title'] = $node->title;
+          
+          if ($defaults['markermode'] == 1) { // popup
+            $marker['text'] = $this->row_plugin->render($row);
+          }
+          else if ($defaults['markermode'] == 2) { // link
+            $marker['link'] = url('node/'. $row->nid);
+          }
+          $markers[] = $marker;
           $offsets[$markername]++;
         }
       }
       if (!empty($markers)) { // Don't draw empty maps.
         $map = gmap_parse_macro($this->options['macro']);
         $map['markers'] = $markers;
+        $map['id'] = gmap_get_auto_mapid();
         $output .= theme($this->theme_functions(), $this->view, $this->options, $map, $title);
       }
     }
@@ -141,67 +131,29 @@ class gmap_plugin_style_gmap extends vie
     );
 
     $form['datasource'] = array(
-      '#type' => 'select',
+      '#type' => 'radios',
       '#title' => t('Data Source'),
       '#options' => array(
         'location' => t('Location.module'),
-        'fields' => t('Choose latitude and longitude fields'),
+        'autodetect' => t('Fields named "latitude" and "longitude" @@@TODO'),
       //'geocode' => t('Just-in-time geocoding on field named "address"'),
       ),
       '#default_value' => $this->options['datasource'],
       '#multiple' => FALSE,
     );
 
-    $options = array();
-    // @@@ Fix this when I'm not having a monday morning.
-    // There's likely a more "correct" way.
-    foreach ($this->display->display_options['fields'] as $id => $handler) {
-      $data = views_fetch_data($handler['table']);
-      $options[$id] = $handler['label'];
-    }
-
-    $form['latfield'] = array(
-      '#title' => t('Latitude field'),
-      '#description' => t('Format must be degrees decimal.'),
-      '#type' => 'select',
-      '#options' => $options,
-      '#default_value' => $this->options['latfield'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('edit-style-options-datasource' => array('fields')),
-    );
-    $form['lonfield'] = array(
-      '#title' => t('Longitude field'),
-      '#description' => t('Format must be degrees decimal.'),
-      '#type' => 'select',
-      '#options' => $options,
-      '#default_value' => $this->options['lonfield'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('edit-style-options-datasource' => array('fields')),
-    );
-
     $form['markers'] = array(
-      '#type' => 'select',
+      '#type' => 'radios',
       '#title' => t('Marker handling'),
       // @@@ Detect view type automatically?
       '#options' => array(
         'nodetype' => t('By content type (for node views)'),
         'taxonomy' => t('By term (for node views)'),
-        'field' => t('Use marker field'),
         'static' => t('Use single marker type'),
       ),
       '#default_value' => $this->options['markers'],
     );
 
-    $form['markerfield'] = array(
-      '#type' => 'select',
-      '#title' => t('Marker field'),
-      '#description' => t('You can use a views field to set the <em>markername</em> property of the markers.'),
-      '#options' => $options,
-      '#default_value' => $this->options['markerfield'],
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('edit-style-options-markers' => array('field')),
-    );
-
     // Hide the taxonomy handling if gmap_taxonomy.module isn't installed.
     if (!module_exists('gmap_taxonomy')) {
       unset($form['markers']['#options']['taxonomy']);
