function template_preprocess_gmap_views_view_gmapextended in GMap Module 7
Same name and namespace in other branches
- 7.2 gmap.views.inc \template_preprocess_gmap_views_view_gmapextended()
File
- ./gmap.views.inc, line 36
- GMap Views support.
Code
function template_preprocess_gmap_views_view_gmapextended(&$vars) {
$view = $vars['view'];
$result = $vars['result'] = $vars['rows'];
$vars['rows'] = array();
$options = $view->style_plugin->options;
$handler = $view->style_plugin;
$fields =& $view->field;
if ($view->style_plugin->options['center_on_proximityfilter'] && $view->style_plugin->options['datasource'] == 'location' && module_exists('location')) {
$vars['center'] = location_views_proximity_get_reference_location($view, array(
'origin' => 'tied',
'relationship' => $view->style_plugin->options['center_on_proximityfilter_rel'],
));
}
$renders = $handler
->render_fields($result);
$markers = array();
foreach ($renders as $i => $row) {
$markers[$i] = $options['fallback_values'];
foreach ($options['field_purposes'] as $field => $purpose) {
if (!isset($markers[$i][$purpose])) {
$markers[$i][$purpose] = '';
}
$markers[$i][$purpose] .= $row[$field];
}
}
foreach ($markers as $offset => $marker) {
$markers[$offset]['opts'] = array(
'title' => isset($marker['title']) ? decode_entities($marker['title']) : NULL,
);
switch ($options['clickmode']) {
case 'render':
$markers[$offset]['text'] = $vars['result'][$offset];
case 'text':
unset($markers[$offset]['link']);
unset($markers[$offset]['rmt']);
unset($markers[$offset]['iwq']);
unset($markers[$offset]['iwo']);
break;
case 'rmt':
unset($markers[$offset]['text']);
unset($markers[$offset]['link']);
unset($markers[$offset]['iwq']);
unset($markers[$offset]['iwo']);
break;
case 'link':
unset($markers[$offset]['text']);
unset($markers[$offset]['rmt']);
unset($markers[$offset]['iwq']);
unset($markers[$offset]['iwo']);
break;
case 'iwq':
$markers[$offset]['iwq'] = trim($markers[$offset]['iwq']);
$markers[$offset]['iwo'] = (int) trim($markers[$offset]['iwo']);
if (empty($markers[$offset]['iwq']) || $markers[$offset]['iwq'] == $options['iwq']) {
unset($markers[$offset]['iwq']);
}
unset($markers[$offset]['text']);
unset($markers[$offset]['link']);
unset($markers[$offset]['rmt']);
break;
}
}
foreach ($markers as $offset => $marker) {
$marker['latitude'] = isset($marker['latitude']) ? (double) $marker['latitude'] : NULL;
$marker['longitude'] = isset($marker['longitude']) ? (double) $marker['longitude'] : NULL;
}
$vars['markers'] = $markers;
}