Beispiel #1
0
function geopress_page_map($width = "", $height = "", $controls = true)
{
    global $post, $geopress_map_index;
    // $children = get_children("post_parent=".$post->post_id."&post_type=page&orderby=menu_order ASC post_date&order=ASC");
    $children = get_children("post_parent=" . $post->ID . "&orderby=menu_order ASC, post_date&order=ASC");
    $output = '';
    if ($children == false) {
        $output .= geopress_post_map($height, $width, $controls);
    } else {
        $map_format = get_settings('_geopress_map_format', true);
        if ($height == "" || $width == "") {
            $width = get_settings('_geopress_mapwidth', true);
            $height = get_settings('_geopress_mapheight', true) * 2;
        }
        $map_id = $post->ID . $geopress_map_index;
        $coords = split(" ", $geo->coord);
        $map_controls = $controls ? GeoPress::mapstraction_map_controls() : "false";
        $output = '<div id="geo_map' . $map_id . '" class="mapstraction" style="height: ' . $height . 'px; width: ' . $width . 'px;"></div>';
        $output .= '<!-- GeoPress Map --><script type="text/javascript">';
        $output .= 'geopress_addEvent(window,"load", function() { geopress_maketravelmap(';
        $output .= $map_id . ',';
        $output .= '{';
        $pointList = array();
        foreach ($children as $key => $value) {
            $line = "";
            $geo = GeoPress::get_geo($key);
            if ($geo) {
                $line .= $key . ':{';
                $coords = split(" ", $geo->coord);
                $line .= 'lat:' . $coords[0] . ',lng:' . $coords[1];
                $line .= ',name:"' . addslashes($geo->name) . '"';
                //				$line .= ',title:"'.'"guid."'title='".addslashes($value->post_title) . "'>".addslashes($value->post_title)."".'"';
                $line .= '}';
                array_push($pointList, $line);
            }
        }
        $output .= implode(',', $pointList);
        $output .= '},';
        $output .= '"' . GeoPress::mapstraction_map_format($geo->map_format) . '",' . GeoPress::mapstraction_map_type($geo->map_type) . ', ' . $map_controls . ')';
        $output .= "}); </script><!-- end GeoPress Map -->";
    }
    return $output;
}
Beispiel #2
0
 function embed_map_inpost($content)
 {
     $default_add_map = get_settings('_geopress_default_add_map', true);
     // If the user explicitly wants to insert a map
     if (preg_match_all('/INSERT_MAP/', $content, $matches) > 0) {
         $content = preg_replace("/INSERT_MAP\\((\\d+),[ ]?(\\d+)\\)/", geopress_post_map('\\1', '\\2'), $content);
         $content = preg_replace("/INSERT_OVERLAY_MAP\\((\\d+),[ ]?(\\d+),[ ]?(.+)\\)/", geopress_post_map('\\1', '\\2', true, '\\3'), $content);
         $content = preg_replace("/INSERT_MAP/", geopress_post_map(), $content);
         // This can probably be made into a single preg_replace with ? optionals - ajturner //
     } elseif (preg_match_all('/INSERT_GEOPRESS_MAP/', $content, $matches) > 0) {
         $content = preg_replace("/INSERT_GEOPRESS_MAP\\((\\d+),[ ]?(\\d+)\\)/", geopress_map('\\1', '\\2'), $content);
         $content = preg_replace("/INSERT_GEOPRESS_MAP/", geopress_map(), $content);
         // This can probably be made into a single preg_replace with ? optionals - ajturner //
     } elseif ($default_add_map == 2 || is_single() && $default_add_map == 1) {
         // Add a map to the end of the post if "automatically add map" is enabled
         $content .= geopress_post_map();
     }
     $content = preg_replace("/GEOPRESS_LOCATION\\((.+)\\)/", "", $content);
     return $content;
 }