Index: gmap.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap.module,v retrieving revision 1.104.2.4 diff -u -p -r1.104.2.4 gmap.module --- gmap.module 24 Jan 2010 04:17:30 -0000 1.104.2.4 +++ gmap.module 25 Mar 2010 22:45:23 -0000 @@ -119,6 +119,7 @@ function gmap_gmap($op, &$map) { drupal_add_js($path . 'icon.js'); drupal_add_js($path . 'marker.js'); + drupal_add_js($path .'highlight.js'); $mm = variable_get('gmap_mm_type', 'gmap'); // If you really really want to override the marker manager, implement @@ -220,6 +221,18 @@ function gmap_gmap($op, &$map) { 'help' => t('Used for advanced javascript work, this will enable the clickshape event.'), 'internal' => TRUE, ), + 'googlebar' => array( + 'title' => t('Enable Google Bar'), + 'default' => FALSE, + 'help' => t('Enable the "Google Bar" at bottom.'), + 'previewable' => TRUE, + ), + 'highlight' => array( + 'title' => t('Highlight marker on rollover'), + 'default' => FALSE, + 'help' => t('Highlight marker by creating circle on mouse rollover event.'), + 'previewable' => TRUE, + ), ); break; @@ -279,6 +292,7 @@ function _gmap_doheader() { drupal_add_js($gmap_path . '/thirdparty/' . $mms[$mm]['filename']); } drupal_add_js($gmap_path . '/js/marker.js'); + drupal_add_js($gmap_path . '/js/highlight.js'); drupal_add_js($gmap_path . '/js/' . $mm . '_marker.js'); drupal_add_js(array('gmap_markermanager' => $mms[$mm]), 'setting'); // @@@ Index: gmap_plugin_style_gmap.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/gmap/gmap_plugin_style_gmap.inc,v retrieving revision 1.11 diff -u -p -r1.11 gmap_plugin_style_gmap.inc --- gmap_plugin_style_gmap.inc 15 Dec 2009 18:39:26 -0000 1.11 +++ gmap_plugin_style_gmap.inc 25 Mar 2010 22:45:23 -0000 @@ -29,10 +29,15 @@ class gmap_plugin_style_gmap extends vie $options['markers'] = array('default' => 'static'); $options['markertype'] = array('default' => 'drupal'); + $options['center_on_nodearg'] = array('default' => '0'); + $options['highlight_nodearg'] = array('default' => '0'); + $options['latfield'] = array('default' => ''); $options['lonfield'] = array('default' => ''); $options['markerfield'] = array('default' => ''); + $options['tooltipfield'] = array('default' => ''); + return $options; } @@ -76,14 +81,17 @@ class gmap_plugin_style_gmap extends vie $lat_field = 'gmap_lat'; $lon_field = 'gmap_lon'; + $tooltip_field = 'gmap_tooltip'; // Determine fieldname for latitude and longitude fields. if ($this->options['datasource'] == 'fields') { $lat_fied_obj = $this->view->display_handler->get_handler('field', $this->options['latfield']); $lon_field_obj = $this->view->display_handler->get_handler('field', $this->options['lonfield']); + $tooltip_field_obj = $this->view->display_handler->get_handler('field', $this->options['tooltipfield']); $lat_field = $lat_fied_obj->field_alias; $lon_field = $lon_field_obj->field_alias; + $tooltip_field = $tooltip_field_obj->field_alias; } // Determine fieldname for marker field. @@ -111,10 +119,35 @@ class gmap_plugin_style_gmap extends vie foreach ($sets as $title => $records) { $markers = array(); $offsets = array(); + $lat_center = null; + $lon_center = null; + $nid_center = null; + $nid_highlight = 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(); + } + if ($this->options['highlight_nodearg'] && $nodehandler = $this->view->display_handler->get_handler('argument', 'null')) { + $nid_highlight = $nodehandler->get_value(); + } + foreach ($records as $row_index => $row) { $this->view->row_index = $row_index; $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; + } + + $tooltip = ""; + if (!empty($tooltip_field)) { + $tooltip = $row->{$tooltip_field}; + } + if (!empty($lat) && !empty($lon)) { if ($this->options['markers'] == 'nodetype') { if (isset($markertypes[$row->gmap_node_type])) { @@ -148,12 +181,20 @@ class gmap_plugin_style_gmap extends vie 'markername' => $markername, 'offset' => $offsets[$markername], 'text' => $this->row_plugin->render($row), + 'opts' => array('title' => $tooltip), ); $offsets[$markername]++; } } 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); } @@ -167,13 +208,34 @@ class gmap_plugin_style_gmap extends vie */ 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['highlight_nodearg'] = array( + '#type' => 'checkbox', + '#title' => t('Highlight marker for node argument'), + '#default_value' => $this->options['highlight_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'), '#size' => 1000, '#default_value' => $this->options['macro'], ); - + $form['tooltipfield'] = array( + '#title' => t('Tooltip field'), + '#description' => t('Format must be text'), + '#type' => 'select', + '#options' => $options, + '#default_value' => $this->options['tooltipfield'], + '#process' => array('views_process_dependency'), + '#dependency' => array('edit-style-options-datasource' => array('fields')), + ); $form['datasource'] = array( '#type' => 'select', '#title' => t('Data Source'), Index: js/gmap.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/gmap/js/gmap.js,v retrieving revision 1.16 diff -u -p -r1.16 gmap.js --- js/gmap.js 1 Dec 2009 19:47:53 -0000 1.16 +++ js/gmap.js 25 Mar 2010 22:45:23 -0000 @@ -300,6 +300,9 @@ Drupal.gmap.addHandler('gmap', function if (obj.vars.behavior.overview) { map.addControl(new GOverviewMapControl()); } + if (obj.vars.behavior.googlebar) { + map.enableGoogleBar(); + } if (obj.vars.behavior.scale) { map.addControl(new GScaleControl()); } Index: js/highlight.js =================================================================== RCS file: js/highlight.js diff -N js/highlight.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ js/highlight.js 25 Mar 2010 22:45:23 -0000 @@ -0,0 +1,51 @@ +/* $Id: highlight.js,v 1.0 2009/05/09 19:12:12 srobert72 Exp $ */ + +/** + * @file + * Common marker highlighting routines. + */ + +/*global $, Drupal */ + +/** + * Highlights marker on rollover. + * Removes highlight on previous marker. + * + * Creates a "circle" using 20-sided GPolygon at the given point + * Circle polygon object is global variable as there is only one highlighted marker at a time + * and we want to remove the previously placed polygon before placing a new one. + * + * Original code "Google Maps JavaScript API Example" + */ +var highlightCircle; +highlightCurrentMarker = function (map, currentMarker) { + var markerPoint = currentMarker.marker.getPoint(); + + var polyPoints = Array(); + + if (highlightCircle) { + map.removeOverlay(highlightCircle); + } + + var mapNormalProj = G_NORMAL_MAP.getProjection(); + var mapZoom = map.getZoom(); + var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom); + + var polySmallRadius = 20; + + var polyNumSides = 20; + var polySideLength = 18; + + for (var a = 0; a<(polyNumSides+1); a++) { + var aRad = polySideLength*a*(Math.PI/180); + var polyRadius = polySmallRadius; + var pixelX = clickedPixel.x + polyRadius * Math.cos(aRad); + var pixelY = clickedPixel.y + polyRadius * Math.sin(aRad); + var polyPixel = new GPoint(pixelX,pixelY); + var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel,mapZoom); + polyPoints.push(polyPoint); + } + // Using GPolygon(points, strokeColor?, strokeWeight?, strokeOpacity?, fillColor?, fillOpacity?) + highlightCircle = new GPolygon(polyPoints,"#000000",2,0.0,"#FF0000",.5); + map.addOverlay(highlightCircle); +}; Index: js/marker.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/gmap/js/marker.js,v retrieving revision 1.4 diff -u -p -r1.4 marker.js --- js/marker.js 11 Feb 2009 19:12:12 -0000 1.4 +++ js/marker.js 25 Mar 2010 22:45:23 -0000 @@ -22,6 +22,11 @@ Drupal.gmap.addHandler('gmap', function GEvent.addListener(m, 'click', function () { obj.change('clickmarker', -1, marker); }); + if (obj.vars.behavior.highlight) { + GEvent.addListener(m, 'mouseover', function () { + obj.change('mouseovermarker', -1, marker); + }); + } if (obj.vars.behavior.extramarkerevents) { GEvent.addListener(m, 'mouseover', function () { obj.change('mouseovermarker', -1, marker); @@ -101,6 +106,10 @@ Drupal.gmap.addHandler('gmap', function obj.bounds = new GLatLngBounds(); } }); + + obj.bind('mouseovermarker', function (marker) { + highlightCurrentMarker(obj.map, marker); + }); // @@@ TODO: Some sort of bounds handling for deletemarker? We'd have to walk the whole thing to figure out the new bounds... });