Drupal 如何在gmap模块中修改工具提示?
我想修改当你点击一个标记时弹出的工具提示信息窗口。我试图在工具提示上嵌入一个文本字段和提交按钮,如本例所示。在template.php中,您可以修改gmap字段的输出。您特别感兴趣的是var$gmaptextDrupal 如何在gmap模块中修改工具提示?,drupal,drupal-modules,drupal-7,Drupal,Drupal Modules,Drupal 7,我想修改当你点击一个标记时弹出的工具提示信息窗口。我试图在工具提示上嵌入一个文本字段和提交按钮,如本例所示。在template.php中,您可以修改gmap字段的输出。您特别感兴趣的是var$gmaptext function salive_preprocess_node(&$vars, $hook) { $vars['gmap'] = salive_render_gmap($vars['node']); } /** * Render a google map from a no
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;
?>
在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;
?>