Skip to content

Commit 3e3d344

Browse files
committed
New map v4
1 parent 5e1278d commit 3e3d344

2 files changed

Lines changed: 573 additions & 0 deletions

File tree

osmmap4.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/***********************************************
3+
* File : osmmap4.php
4+
* Project : piwigo-openstreetmap
5+
* Descr : Display a world map v4
6+
*
7+
* Created : 10.07.2015
8+
*
9+
* Copyright 2013-2015 <xbgmsharp@gmail.com>
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation, either version 3 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
************************************************/
25+
26+
if ( !defined('PHPWG_ROOT_PATH') )
27+
define('PHPWG_ROOT_PATH','../../');
28+
29+
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
30+
include_once( PHPWG_ROOT_PATH.'admin/include/functions.php' );
31+
include_once( dirname(__FILE__) .'/include/functions.php');
32+
include_once( dirname(__FILE__) .'/include/functions_map.php');
33+
34+
check_status(ACCESS_GUEST);
35+
36+
osm_load_language();
37+
load_language('plugin.lang', OSM_PATH);
38+
39+
$section = '';
40+
if ( $conf['question_mark_in_urls']==false and isset($_SERVER["PATH_INFO"]) and !empty($_SERVER["PATH_INFO"]) )
41+
{
42+
$section = $_SERVER["PATH_INFO"];
43+
$section = str_replace('//', '/', $section);
44+
$path_count = count( explode('/', $section) );
45+
$page['root_path'] = PHPWG_ROOT_PATH.str_repeat('../', $path_count-1);
46+
if ( strncmp($page['root_path'], './', 2) == 0 )
47+
{
48+
$page['root_path'] = substr($page['root_path'], 2);
49+
}
50+
}
51+
else
52+
{
53+
foreach ($_GET as $key=>$value)
54+
{
55+
if (!strlen($value)) $section=$key;
56+
break;
57+
}
58+
}
59+
60+
// deleting first "/" if displayed
61+
$tokens = explode('/', preg_replace('#^/#', '', $section));
62+
$next_token = 0;
63+
$result = osm_parse_map_data_url($tokens, $next_token);
64+
$page = array_merge( $page, $result );
65+
66+
67+
if (isset($page['category']))
68+
check_restrictions($page['category']['id']);
69+
70+
/* If the config include parameters get them */
71+
$zoom = isset($conf['osm_conf']['left_menu']['zoom']) ? $conf['osm_conf']['left_menu']['zoom'] : 2;
72+
$center = isset($conf['osm_conf']['left_menu']['center']) ? $conf['osm_conf']['left_menu']['center'] : '0,0';
73+
$center_arr = preg_split('/,/', $center);
74+
$center_lat = isset($center_arr) ? $center_arr[0] : 0;
75+
$center_lng = isset($center_arr) ? $center_arr[1] : 0;
76+
77+
/* If we have zoom and center coordonate, set it otherwise fallback default */
78+
$zoom = isset($_GET['zoom']) ? $_GET['zoom'] : $zoom;
79+
$center_lat = isset($_GET['center_lat']) ? $_GET['center_lat'] : $center_lat;
80+
$center_lng = isset($_GET['center_lng']) ? $_GET['center_lng'] : $center_lng;
81+
82+
$local_conf = array();
83+
$local_conf['zoom'] = $zoom;
84+
$local_conf['center_lat'] = $center_lat;
85+
$local_conf['center_lng'] = $center_lng;
86+
$local_conf['contextmenu'] = 'true';
87+
$local_conf['control'] = true;
88+
$local_conf['img_popup'] = false;
89+
$local_conf['paths'] = osm_get_gps($page);
90+
$local_conf = $local_conf + $conf['osm_conf']['map'] + $conf['osm_conf']['left_menu'];
91+
92+
$js_data = osm_get_items($page);
93+
$js = osm_get_js($conf, $local_conf, $js_data);
94+
osm_gen_template($conf, $js, $js_data, 'osm-map4.tpl', $template);
95+
?>

0 commit comments

Comments
 (0)