Beispiel #1
0
/**
 * Include map backend dependencies
 */
function include_map_dependencies()
{
    global $main, $smarty, $vars;
    // Include needed javascript
    include_js_language_tokens();
    $js_dir = surl($smarty->template_dir . "/scripts/javascripts/");
    if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
        $main->html->head->add_script('text/javascript', 'https://maps.google.com/maps/api/js?v=3&sensor=false');
    } else {
        $main->html->head->add_script('text/javascript', 'http://maps.google.com/maps/api/js?v=3&sensor=false');
    }
    $main->html->head->add_script('text/javascript', "{$js_dir}/map.js");
    $main->html->head->add_script('text/javascript', "{$js_dir}/openlayers/OpenLayers.js");
    $map_options = array();
    $map_options['bound_sw'] = array($vars['map']['bounds']['min_latitude'], $vars['map']['bounds']['min_longitude']);
    $map_options['bound_ne'] = array($vars['map']['bounds']['max_latitude'], $vars['map']['bounds']['max_longitude']);
    $map_options['topology_url'] = make_ref('/map/json', array("node" => get('node')));
    $map_options_string = json_encode($map_options);
    $main->html->head->add_extra("<script type=\"text/javascript\">\r\n\t\t\tmap_options = {$map_options_string};\r\n\t\t\t</script>");
}
Beispiel #2
0
/**
 * Include map to the output
 * @param element_id The id of the element to render map on.
 * @param picker A flag to show that this is a place picker.
 */
function include_map($element_id)
{
    global $main, $smarty, $vars;
    include_map_dependencies();
    // Include needed javascript
    include_js_language_tokens();
    $main->html->head->add_extra("<script type=\"text/javascript\">\n\t\t\t\$(function() {\n\t\t\t\t// Load map\n\t\t\t\tmap = new NetworkMap('{$element_id}', map_options);\n\n\t\t\t\tcontrolNodeFilter = new NetworkMapControlNodeFilter(map);\n\t\t\t\tcontrolFullScreen = new NetworkMapControlFullScreen(map);\n\t\t\t\t\n\t\t\t});\n\t\t\t\n\t\t\t\n\t\t\t</script>");
}