How to modify tooltip in gmap module?
I would like to modify tooltip (info window that p开发者_开发问答ops up when you click on a marker). I'm trying to embed a text field and submit button on the tooltip, like in this example http://econym.org.uk/gmap/example_map4.htm.
In template.php, you can modify the output of the gmap field. Of particular interest to you is the var $gmaptext
function salive_preprocess_node(&$vars, $hook) {
$vars['gmap'] = salive_render_gmap($vars['node']);
}
/**
* Render a google map from a node object from a venue content type
*
* $node is an object, and should have the location fields, like venue content type does.
*/
function salive_render_gmap($node) {
$location = $node->location;
$gmaptext =
$location['name'] . '<br />' .
$location['street'];
if (isset($location['additional'])) {
$gmaptext .= $location['additional'] . '<br />';
}
$gmaptext .= $location['city'] . ', ' . $location['province'] . ' ' . $location['postal_code'] . '<br />';
if (isset($location['phone'])) {
$gmaptext .= $location['phone'];
}
if (isset($field_website[0]['safe'])) {
$gmaptext .= '<br /><a href="' . $field_website[0]['safe'] . '" target="_blank" rel="nofollow">Web site</a>';
}
$map_array = array (
'id' => $node->id, // id attribute for the map
'width' => "580px", // map width in pixels or %
'height' => "400px", // map height in pixels
'latitude' => $location['latitude'], // map center latitude
'longitude' => $location['longitude'], // map center longitude
'zoom' => 15, // zoom level
'maptype' => "Map", // baselayer type
'controltype' => "Small", // size of map controls
'markers' => array(
array(
'text' => $gmaptext,
'longitude' => $location['longitude'],
'latitude' => $location['latitude'],
'markername' => 'big red'
)
)
);
if (count($map_array) < 2) {
drupal_set_message('$map_array was empty');
if (module_exists('devel')) {
dpm($map_array);
}
}
else {
return (theme('gmap', array('#settings' => $map_array)));
}
}
Then, in page.tpl.php:
<?php
if ($gmap):
print $gmap;
endif;
?>
精彩评论