function route_planner_map_display in Route Planner 7
Same name and namespace in other branches
- 6 route_planner.module \route_planner_map_display()
Show a Google Map with a POI or a route.
Return value
HTML output for the map.
1 call to route_planner_map_display()
- route_planner_block_view in ./
route_planner.module - Implements hook_block_view().
File
- ./
route_planner.module, line 219 - The Route Planner module create blocks to show a route from any address to a fixed point.
Code
function route_planner_map_display() {
// Detect protocol to use when calling maps api.
global $is_https;
$protocol = $is_https ? 'https://' : 'http://';
// Add google maps api. Pass parameters "key" and "language" localization.
// Parameter "sensor" is deprecated and no more used.
$key = variable_get('route_planner_api_key', '');
$language = variable_get('route_planner_api_language', '');
drupal_add_js($protocol . 'maps.googleapis.com/maps/api/js?key=' . $key . '&language=' . $language, 'external');
// Add some custom javascript to display the map.
drupal_add_js(drupal_get_path('module', 'route_planner') . '/route_planner.js');
$address = token_replace(variable_get('route_planner_address', 'Hamburg, Germany'));
// This HTML is used in the Addressfield Token.
// We have to replace the stuff with a comma to let Google work with.
$address = str_replace('<span class="postal-code">', ", ", $address);
$address = str_replace('<span class="country">', ', ', $address);
$address = strip_tags($address);
// Set variables from Route Planner settings page.
drupal_add_js(array(
'routePlanner' => array(
'zoomlevel' => variable_get('route_planner_map_zoom', 10),
'zoomcontrol' => variable_get('route_planner_map_zoomcontrol', TRUE),
'scrollwheel' => variable_get('route_planner_map_scrollwheel', TRUE),
'mapTypeControl' => variable_get('route_planner_map_maptypecontrol', TRUE),
'scaleControl' => variable_get('route_planner_map_scalecontrol', TRUE),
'draggable' => variable_get('route_planner_map_draggable', TRUE),
'doubbleclick' => variable_get('route_planner_map_doubbleclick', TRUE),
'streetviewcontrol' => variable_get('route_planner_map_streetviewcontrol', TRUE),
'overviewmapcontrol' => variable_get('route_planner_map_overviewmapcontrol', TRUE),
'unitSystem' => variable_get('route_planner_unitsystem', TRUE),
'defaultui' => variable_get('route_planner_map_defaultui', TRUE),
'end' => variable_get('route_planner_address', 'Hamburg, Germany'),
'style' => variable_get('route_planner_map_style', NULL),
'travelMode' => variable_get('route_planner_map_travelmode', FALSE),
),
), 'setting');
// Output the map.
$output = '<div id="map_canvas" style="height:' . check_plain(variable_get('route_planner_map_height', '300px')) . '; width:' . check_plain(variable_get('route_planner_map_width', '100%')) . ';"></div>';
return $output;
}