我想修改工具提示(单击标记时弹出的信息窗口)。我正在尝试在工具提示中嵌入文本字段和提交按钮,就像在此示例http://econym.org.uk/gmap/example_map4.htm中一样。
答案 0 :(得分:0)
在template.php中,您可以修改gmap字段的输出。你特别感兴趣的是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)));
}
}
然后,在page.tpl.php:
<?php
if ($gmap):
print $gmap;
endif;
?>