4 'https://a.tile.openstreetmap.org/',
5 'https://b.tile.openstreetmap.org/',
6 'https://b.tile.openstreetmap.de/',
8 'http://tile.thunderforest.com/cycle/',
9 'http://tile.thunderforest.com/transport/',
10 'http://tile.thunderforest.com/landscape/',
12 'http://tile.memomaps.de/tilegen/',
13 'https://tiles.wmflabs.org/hikebike/',
15 'http://tile.stamen.com/toner/',
16 'http://tile.stamen.com/toner-hybrid/',
17 'http://tile.stamen.com/toner-labels/',
18 'http://tile.stamen.com/toner-lines/',
19 'http://tile.stamen.com/toner-background/',
20 'http://tile.stamen.com/toner-lite/'
22 // "https://stamen-tiles.a.ssl.fastly.net/toner/"
25 $defLatLon = [ 50.0740, 14.4505 ];
28 // ---------------------- log proxy ------------------------------------------
32 if ( $_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '127.0.0.1' || strstr ($_SERVER['SERVER_NAME'], '10.0.0.') ) {
34 ini_set("log_errors", 1);
35 ini_set("error_log", "/tmp/php-error.log");
37 ini_set("log_errors", 1);
38 ini_set("error_log", "../MYLOG/.php-error.log");
41 function myLog( $message, $var = '' ){
43 global $globalPHPFile;
45 if ( is_array($var) ) $var = print_r( $var, true );
47 error_log( '[' . urldecode(getenv('REQUEST_URI')) . '][' . basename($globalPHPFile, '.php') . '] ' . $message . $var );
50 if ( !isset ($_POST[ 'session_test' ]) ) {
51 myLog( "----------- MAIN -------------" );
52 myLog('REQUEST_URI MAIN: ' . $_SERVER['SERVER_NAME']);
55 ini_set('session.cookie_domain', $_SERVER['SERVER_NAME']);
57 //------------------------------ url parsing ---------------------------------
59 $urlLine = explode('?', rtrim( getenv('REQUEST_URI') , '/') );
60 $url = explode('/', $urlLine[0] );
62 if ( !empty($url[1]) ) $mapNum = $url[1]; else $mapNum = 0;
63 if ( !empty($url[2]) ) $targetLocation = '/maps/' . "$url[2]|$url[3]|$url[4]|$url[5]" . '/'; else $targetLocation = $defMap[ $mapNum ];
64 if ( !empty($url[3]) && !empty($url[4]) ) $targetLatLon = [ $url[3], $url[4] ]; else $targetLatLon = $defLatLon;
65 if ( !empty($url[5]) ) $targetZoom = $url[5]; else $targetZoom = $defZoom;
67 myLog('$targetLocation: ', $targetLocation);
68 myLog('$mapNum: ', $mapNum);
70 // ---------------------------------------------------------------------------
72 exec("ls 'maps/'", $mapList );
74 // ---------------------------------------------------------------------------
78 <script src="/js/jquery-1.11.0.min.js"></script>
80 <link rel="stylesheet" type="text/css" href="/js/leaflet-0.7.5/leaflet.css" />
81 <script src="/js/leaflet-0.7.5/leaflet.js"></script>
86 body { margin: 0; padding: 0 }
87 #map { width: 100%; height: 100% }
88 #debug { position: fixed; color: #fff; padding: 15px 20px; top: 10; right: 10; width: 300px; height: auto; background: rgba(0,0,0,0.5); border-radius: 15px }
89 #debug a { color: #eee; margin-left: -5px; padding: 2px 5px; text-decoration: none; line-height: 25px }
90 #debug a:hover, .select { background: rgba(1,0,0,0.3); border-radius: 15px; color: white; }
94 <div id="map"><!-- --></div>
97 foreach( $mapList as $mapLine ){
98 $map = explode('|', $mapLine);
100 if ( $url[2] == $map[0] ) $select = 'class="select"'; else $select = ''
102 <a href="/<? echo $mapNum ?>/<? echo $map[0]?>/<? echo $map[1]?>/<? echo $map[2]?>/<? echo $map[3]?>" <? echo $select ?>> <?echo $map[0] ?> </a> <br />
108 for( $a = 0; $a < count( $defMap ); $a ++ ){
110 if ( $url[1] == $a ) $select = 'class="select"'; else $select = ''
112 <a href="/<? echo $a ?>/" <? echo $select ?>> <? echo $defMap[ $a ] ?> </a><br />
119 <div id="current"><!-- --></div>
120 <div id="command"><!-- --></div>
128 defPosition = <? echo json_encode($targetLatLon) ?>;
129 defMapZoom = <? echo $targetZoom ?>;
130 mapPath = '<? echo $targetLocation ?>';
132 // var map = L.map('map', { zoomControl:false, attributionControl:false, fadeAnimation:false, zoomAnimation:false }).setView([ defLat, defLon ], defMapZoom);
133 map = L.map('map').setView( defPosition, defMapZoom);
135 // mapObj = L.tileLayer( 'http://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png');
136 mapObj = L.tileLayer( mapPath + '{z}/{x}/{y}.png');
138 map.addLayer( mapObj );
144 var clc = [[0, 0][0, 0]];
146 function displayCommand(){
147 debugTxt = clc[0][0] + ' ' + clc[0][1] + ' ' + clc[1][0] + ' ' + clc[1][1] + ' ' + map.getZoom();
148 $('#debug #command').html( debugTxt );
151 function displayCurrent(){
152 debugTxt = lat + ' ' + lng + ' ' + map.getZoom();
153 $('#debug #current').html( debugTxt );
156 map.addEventListener('click', function(ev) {
157 lat = Number(ev.latlng.lat).toFixed(5);
158 lng = Number(ev.latlng.lng).toFixed(5);
162 clc[ cl ] = [ lat, lng ];
165 if (rect) map.removeLayer( rect );
166 var rect = L.rectangle( [clc[0], clc[1]] , {color: 'blue', weight: 1}).addTo(map);
170 marker = L.marker( ev.latlng,{ draggable: false } ).addTo( map );
172 if (cl < 1) cl++; else cl = 0;
176 map.on('zoomend', function() {