Beispiel #1
0
function main()
{
    $action = $_REQUEST['action'];
    if (isset($action)) {
        switch ($action) {
            case "save_map":
                save_map($_REQUEST);
                break;
            case "show_tiles":
                show_tiles();
                break;
            case "show_maps":
                show_maps();
                break;
            case "load_map":
                load_map($_REQUEST['map']);
                break;
            default:
                echo 'invalid action';
        }
    }
}
     $vars['map_objects'] = SiteMaps::getMapsObjects();
     $vars['html_title'] = $lang_msg['MAP_GLOBAL_TITLE'];
     $vars['page_title'] = $lang_msg['MAP_GLOBAL_PAGE_TITLE'];
     // redirect the page to map view
     $page = 'map_view';
     break;
 case "map_create":
     $vars['html_title'] = $lang_msg['MAP_CREATE_TITLE'];
     $vars['page_title'] = $lang_msg['MAP_CREATE_PAGE_TITLE'];
     break;
 case "map_edit":
     if (isset($_POST['map_id'])) {
         $map_id = intval($_POST['map_id']);
     }
     if ($map_id > 0) {
         $vars_tmp = load_map(intval($map_id));
     } else {
         $vars['error_msg'] .= 'Not valid map id';
     }
     $vars['html_title'] = $lang_msg['MAP_EDIT_TITLE'];
     $vars['page_title'] = $lang_msg['MAP_EDIT_PAGE_TITLE'];
     break;
 case "map_save":
     $post_list = array();
     $post_list['map_id'] = isset($_POST['map_id']) ? $_POST['map_id'] : 0;
     $post_list['map_title'] = isset($_POST['map_title']) ? $_POST['map_title'] : '';
     $post_list['map_description'] = isset($_POST['map_description']) ? $_POST['map_description'] : '';
     $post_list['map_center_lat'] = isset($_POST['map_center_lat']) ? $_POST['map_center_lat'] : 0;
     $post_list['map_center_lng'] = isset($_POST['map_center_lng']) ? $_POST['map_center_lng'] : 0;
     $post_list['map_zoom'] = isset($_POST['map_zoom']) ? $_POST['map_zoom'] : '';
     $post_list['map_typeid'] = isset($_POST['map_typeid']) ? $_POST['map_typeid'] : '';
Beispiel #3
0
<?php

include "../lib.php";
$name = $_GET['name'];
$map = load_map($name);
if ($map["status"] == "ERROR") {
    echo "ERROR: {$map["message"]}\n";
} else {
    echo $map["json"];
}
/**
 * Load single location map using `load_map_info`
 */
function load_location()
{
    global $post;
    $location_array;
    $args = array('post_type' => 'location', 'p' => $post->ID, 'post_status' => array('publish', 'private'), 'posts_per_page' => -1);
    $wp_query = new WP_Query($args);
    if ($wp_query->have_posts()) {
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            $location_array .= "[" . get_field('location')['coordinates'] . ",'" . get_the_title() . "','','" . get_permalink() . "'],";
            $map_centre = "new google.maps.LatLng(" . get_field('location')['coordinates'] . ")";
        }
    }
    load_map($map_centre, 15, false, $location_array, "''", false, false);
}
/**
 * Google Maps Draw Module
 * @package drawonmaps
 * 
 * Class: SiteConf
 * File: functions.php
 * Description: General functions of the tool
 */
function save_map($post_list)
{
    $vars_tmp = array();
    $map_id = $post_list['map_id'];
    if ($map_id > 0) {
        try {
            $map = new Map($map_id);
        } catch (Exception $e) {
            $vars_tmp['error_msg'] = $e->getMessage();
        }
    } else {
        $map = new Map();
    }
    $map->title = trim($post_list['map_title']);
    $map->description = trim($post_list['map_description']);
    $map->center_lat = $post_list['map_center_lat'];
    $map->center_lng = $post_list['map_center_lng'];
    $map->zoom = intval($post_list['map_zoom']);
    $map->typeid = trim($post_list['map_typeid']);
    $map->user_id = 0;
    $result = $map->save();
    if ($result) {
        //load the new created map
        $map = new Map($result);
        $vars_tmp['map'] = $map;
        $vars_tmp['error_msg'] = '';
        if ($map_id > 0) {
            // delete map objects only for existing maps
            $map->deleteMapObjects();
        }
        if ($post_list['marker_title']) {
            foreach ($post_list['marker_title'] as $key => $n) {
                // new map marker record created
                $get_object_id = $map->updateMapObject($n, $post_list['marker_coords'][$key], 1, null, $post_list['marker_icon'][$key]);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['line_title']) {
            foreach ($post_list['line_title'] as $key => $n) {
                // new map polyline record created
                $get_object_id = $map->updateMapObject($n, $post_list['line_coords'][$key], 2);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['poly_title']) {
            foreach ($post_list['poly_title'] as $key => $n) {
                // new map polygon record created
                $get_object_id = $map->updateMapObject($n, $post_list['poly_coords'][$key], 3);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['rect_title']) {
            foreach ($post_list['rect_title'] as $key => $n) {
                // new map rectagle record created
                $get_object_id = $map->updateMapObject($n, $post_list['rect_coords'][$key], 4);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
        if ($post_list['circle_title']) {
            foreach ($post_list['circle_title'] as $key => $n) {
                // new map circle record created
                $get_object_id = $map->updateMapObject($n, $post_list['circle_coords'][$key], 5);
                if (!$get_object_id[0]) {
                    $vars_tmp['error_msg'] .= $get_object_id[1];
                }
            }
        }
    }
    $vars_tmp['success_msg'] = 'The map <strong>' . $map->title . '</strong> saved successfully';
    $vars_load = load_map($map->id);
    if (is_array($vars_load)) {
        $vars_tmp = array_merge($vars_tmp, $vars_load);
    }
    return $vars_tmp;
}