Skip to content
Snippets Groups Projects
Commit 5395ece9 authored by Brandon Bergren's avatar Brandon Bergren
Browse files

#623234: Fix gmap style plugin for Views 2.7.

Also, fix a warning caused by neglecting to give the row plugin a chance to query.
Additionally, ensure that views knows we are capable of doing grouping.
The fix is based on the changes presented in #619884 for views.
parent 83e878d9
No related branches found
No related tags found
No related merge requests found
...@@ -1201,6 +1201,7 @@ function gmap_views_plugins() { ...@@ -1201,6 +1201,7 @@ function gmap_views_plugins() {
'handler' => 'gmap_plugin_style_gmap', 'handler' => 'gmap_plugin_style_gmap',
'theme' => 'gmap_view_gmap', 'theme' => 'gmap_view_gmap',
'uses row plugin' => TRUE, 'uses row plugin' => TRUE,
'uses grouping' => TRUE,
'uses options' => TRUE, 'uses options' => TRUE,
'type' => 'normal', 'type' => 'normal',
), ),
......
...@@ -37,6 +37,8 @@ class gmap_plugin_style_gmap extends views_plugin_style { ...@@ -37,6 +37,8 @@ class gmap_plugin_style_gmap extends views_plugin_style {
} }
function query() { function query() {
parent::query();
if ($this->options['datasource'] == 'location') { if ($this->options['datasource'] == 'location') {
$table = $this->view->query->ensure_table('location'); $table = $this->view->query->ensure_table('location');
$this->view->query->add_field($table, 'latitude', 'gmap_lat'); $this->view->query->add_field($table, 'latitude', 'gmap_lat');
...@@ -52,9 +54,17 @@ class gmap_plugin_style_gmap extends views_plugin_style { ...@@ -52,9 +54,17 @@ class gmap_plugin_style_gmap extends views_plugin_style {
else if ($this->options['markers'] == 'userrole') { else if ($this->options['markers'] == 'userrole') {
$this->view->query->add_field('users_roles', 'rid', 'gmap_role_marker'); $this->view->query->add_field('users_roles', 'rid', 'gmap_role_marker');
} }
if (isset($this->row_plugin)) {
$this->row_plugin->query();
}
} }
/**
* Render the display in this style.
*/
function render() { function render() {
if (isset($this->view->live_preview) && $this->view->live_preview) { if (isset($this->view->live_preview) && $this->view->live_preview) {
return t('GMap views are not compatible with live preview.'); return t('GMap views are not compatible with live preview.');
} }
...@@ -97,7 +107,8 @@ class gmap_plugin_style_gmap extends views_plugin_style { ...@@ -97,7 +107,8 @@ class gmap_plugin_style_gmap extends views_plugin_style {
foreach ($sets as $title => $records) { foreach ($sets as $title => $records) {
$markers = array(); $markers = array();
$offsets = array(); $offsets = array();
foreach ($records as $label => $row) { foreach ($records as $row_index => $row) {
$this->view->row_index = $row_index;
$lat = (float)$row->{$lat_field}; $lat = (float)$row->{$lat_field};
$lon = (float)$row->{$lon_field}; $lon = (float)$row->{$lon_field};
if (!empty($lat) && !empty($lon)) { if (!empty($lat) && !empty($lon)) {
...@@ -143,6 +154,7 @@ class gmap_plugin_style_gmap extends views_plugin_style { ...@@ -143,6 +154,7 @@ class gmap_plugin_style_gmap extends views_plugin_style {
$output .= theme($this->theme_functions(), $this->view, $this->options, $map, $title); $output .= theme($this->theme_functions(), $this->view, $this->options, $map, $title);
} }
} }
unset($this->view->row_index);
return $output; return $output;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment