-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanels_gmap.module
57 lines (50 loc) · 1.66 KB
/
panels_gmap.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Implementation of hook_ctools_plugin_api().
*/
function panels_gmap_ctools_plugin_api($module, $api) {
if ($module == 'page_manager' && $api == 'pages_default') {
return array('version' => 1);
}
}
/**
* Implementation of hook_ctools_plugin_directory().
*
* Tells CTools (and thus Panels) where to look for plugin code.
*/
function panels_gmap_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools' || $module == 'panels') {
return 'plugins/' . $plugin;
}
}
/**
* Implementation of hook_theme().
*/
function panels_gmap_theme($existing, $type, $theme, $path) {
return array(
'panels_google_maps' => array(
'arguments' => array('node' => NULL, 'width' => NULL, 'height' => NULL, 'zoom' => NULL, 'field' => NULL),
'template' => 'panels_gmap',
'preprocess functions' => array('panels_gmap_preprocess_google_maps'),
),
);
}
/**
* Preprocess hook for the google maps.
*/
function panels_gmap_preprocess_google_maps(&$variables, $hook) {
$node = $variables['node'];
// Find localtion fields
$field = $variables['field'];
$locations = $node->$field;
if (isset($locations[0]) && isset($locations[0]['latitude'])) {
$variables['title'] = check_plain($node->title);
$variables['map'] = gmap_simple_map($locations[0]['latitude'],
$locations[0]['longitude'],
'',
check_plain($node->title),
$variables['zoom'],
$variables['width'].'px',
$variables['height'].'px');
}
}