jablonka.czprosek.czf

czfgmap

Subversion Repositories:
[/] [index.php] - Blame information for rev 5

 

Line No. Rev Author Line
15simandl<?php
2//<!-- Copyright (C) 2008 Petr Simandl www.simandl.cz -->
3//<!-- This file is part of CZFGmap. -->
4//<!-- -->
5//<!-- CZFGmap is free software: you can redistribute it and/or modify -->
6//<!-- it under the terms of the GNU General Public License as published by -->
7//<!-- the Free Software Foundation, either version 3 of the License, or -->
8//<!-- (at your option) any later version. -->
9//<!-- -->
10//<!-- CZFGmap is distributed in the hope that it will be useful, -->
11//<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
12//<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
13//<!-- GNU General Public License for more details. -->
14//<!-- -->
15//<!-- You should have received a copy of the GNU General Public License -->
16//<!-- along with CZFGmap. If not, see <http://www.gnu.org/licenses/>. -->
17 
18error_reporting(7);
19 
20include("../forum/globalmap.php");
21 
22switch (@$_SERVER['SERVER_NAME']) {
23 case "connected.czf":
24 $GMapKey="ABQIAAAAvGTA14kOdSvtr3t8EjKUdxQ2n1pNbYRLwYPuGT94C-0un95jGhSkgS0a3LnGa2MzRepHicK08lDDmg";
25 break;
26 case "mapa.prosek.czf":
27 $GMapKey="ABQIAAAAlZ9uhPay2OYt2xmaN84g0BTYUdkyQZ68wktXWB9o4y2agzv8zxRyBxtFdIbLe18hmqHTwiWPXl7VxA";
28 break;
29 default:
30 $GMapKey="ABQIAAAAlZ9uhPay2OYt2xmaN84g0BTYUdkyQZ68wktXWB9o4y2agzv8zxRyBxtFdIbLe18hmqHTwiWPXl7VxA";
31}
32 
33echo '
341simandl<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
35 
36 
37<html xmlns="http://www.w3.org/1999/xhtml">
38 <head>
39 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
403simandl <title>CZFGmap</title>
411simandl <META name="AUTHOR" content="Petr Simandl, www.simandl.cz">
42 <META name="LICENSE" content="GNU General Public License">
43 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
44 <link REL="SHORTCUT ICON" HREF="favicon.ico">
45 <style type="text/css">
46 @import url("http://www.google.com/uds/css/gsearch.css");
47 @import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
48 @import "czfgmap.css";
49 }
50 </style>
515simandl <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key='.$GMapKey.'"
521simandl type="text/javascript"></script>
53 <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0" type="text/javascript"></script>
54 <script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>
55 <script type="text/javascript">
56 
57 //### Globalni promenne #################################
58 var CurrentDatabase = "czfmutf";
59 var NodeLimit = "200";
60 var NodeOrder = "ASC";
61 var NodeSortBy = "name";
62 var Where = "";
63 var LoadedNodes = new Array();
64 var map;
65 var NodeIcon =new Array();
66 var DatabaseNodeTables =new Array();
67 var AutoFetchMode = true;
68 var AutoClearMode = true;
69 var NumLoadedNodes = 0;
70 var NumAddedNodes = 0;
71 var NumLoadedLinks = 0;
72 var NumAddedLinks = 0;
73 var NumVisibleLinks = 0;
74 var NumInVisibleLinks = 0;
753simandl 
76 var LinkColType =new Array();
774simandl LinkColType["00000001"] = "#00aa00";
783simandl LinkColType["00000001"] = "#00FF00";
79 var LinkColTypeWifiBackbone = "#fafa00";
80 LinkColType["00000002"] = "#be0000";
81 LinkColType["00000006"] = "#ff5050";
82 LinkColType["00000003"] = "#64c8ff";
83 LinkColType["00000004"] = "#dc00dc";
84 LinkColType["00000007"] = "#c8c8c8";
85 LinkColType["00000008"] = "#ffffff";
86 LinkColType["00000009"] = "#fa8000";
87 LinkColType["00000099"] = "#0000fa";
88 var LinkColTypeNA = "#78783c";
89 LinkColType["00000005"] = "#00fafa";
901simandl 
91 //nacteni ikon pro nody
92 var NodeType = [0,1,9,10,98,99];
93 var NodeState = [1,9,10,40,79,80,90];
94 for (type in NodeType) {
95 for (state in NodeState) {
96 i = 10000 + NodeType[type]*100 + NodeState[state];
97 NodeIcon[i] = new GIcon();
985simandl NodeIcon[i].image = "./images/node/node-" + NodeType[type] + "-" + NodeState[state] + ".png";
991simandl NodeIcon[i].iconSize = new GSize(15,15);
100 NodeIcon[i].iconAnchor = new GPoint(7,7);
101 NodeIcon[i].shadowSize = new GSize(22,20);
102 NodeIcon[i].infoWindowAnchor = new GPoint(5,1);
103 }
104 }
105 
106 //### Uvodni funkce #################################
107 function load() {
108 if (GBrowserIsCompatible()) {
1095simandl map = new GMap2(document.getElementById("map"),{draggableCursor: \'crosshair\', draggingCursor: \'pointer\'});
1101simandl map.addControl(new GLargeMapControl());
111 map.addControl(new GMapTypeControl());
112 map.addControl(new GOverviewMapControl());
113 map.setCenter(new GLatLng(50.123567, 14.496258), 15);
114 map.enableScrollWheelZoom();
115 map.addControl(new GScaleControl());
116 
117 map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20)));
118 //tohle zajisti znovunacteni nodu po presunu
119 GEvent.addListener(map, "moveend", HandleMapMoveEnd);
120 
1212simandl //ziskani souradnic po kliknuti
1225simandl GEvent.addListener(map, \'click\', function(overlay, point) { if(point) { document.getElementById("NodeCoordinates").innerHTML = (point.y.toFixed(6)+\'x\'+point.x.toFixed(6)); }} );
1232simandl 
1241simandl //tohle zajisti vypis pri startu
125 var center = map.getCenter();
126 document.getElementById("souradnice").innerHTML = CurrentDatabase + "<br>Souradnice stredu:" + center.toString() + "<br>Rozsah: " + map.getBounds()+"<br>Zvetseni: " + map.getZoom();
127 
128 //tohle zajisti prubezny vypis
129 GEvent.addListener(map, "moveend", function() {
130 var center = map.getCenter();
131 document.getElementById("souradnice").innerHTML = CurrentDatabase + " " + map.getBounds().getSouthWest().lat() + "<br>Souradnice stredu: " + center.toString() + "<br>Rozsah: " + map.getBounds()+"<br>Zvetseni: " + map.getZoom();
132 });
133 
134 document.getElementById("AutoFetchModeCheckButton").checked = true;
135 document.getElementById("AutoClearModeCheckButton").checked = true;
136 document.getElementById("NodeLimitSelectBox").value = NodeLimit;
137 document.getElementById("databaze").innerHTML = CurrentDatabase;
138 
139 //prvotni zobrazeni
140 ClearOverlayAndData();
141 NodeLayer();
1424simandl 
143 var pts = new Array();
144 
145// pts.push (new GLatLng(50.120771, 14.486246));
146 pts.push (new GLatLng(50.118212, 14.484079));
147 pts.push (new GLatLng(50.118707, 14.491160));
148 
149 poly = new BDCCPolyline(pts,"#FF0000",3,0.3,"Tohle je pokusny objekt","dash");
150 
151 map.addOverlay(poly);
152 
153 GEvent.addListener(poly,"click",function(){alert(poly.tooltip);});
154 GEvent.addListener(poly,"mouseover",function(){poly.setOpacity(0.8);});
155 GEvent.addListener(poly,"mouseout",function(){poly.setOpacity(0.3);});
1561simandl }
157 }
158 
159 //### Ostatni funkce ###########################
160 
161 function NodeLayer() {
162 //body se berou z databaze pomoci php skriptu ktery dela jen inteface a generuje xml
163 Where = "";
164 GDownloadUrl("mapa_genxml.php?db="+CurrentDatabase
165 +"&latmin="+map.getBounds().getSouthWest().lat()
166 +"&latmax="+map.getBounds().getNorthEast().lat()
167 +"&lonmin="+map.getBounds().getSouthWest().lng()
168 +"&lonmax="+map.getBounds().getNorthEast().lng()
169 +"&sortby="+NodeSortBy
170 +"&limit="+NodeLimit
171 +"&order="+NodeOrder
172 +"&where="+Where
173 +"&zoom="+map.getZoom()
174 , function(data) {
175 var xml = GXml.parse(data);
176 var nodes = xml.documentElement.getElementsByTagName("node");
177 for (var i = 0; i < nodes.length; i++) {
178 var id = nodes[i].getAttribute("id");
179 //zobrazime jen nove nody
180 if (! LoadedNodes[id]) {
181 var name = nodes[i].getAttribute("name");
182 var address = nodes[i].getAttribute("address");
183 var type = 10000 + nodes[i].getAttribute("type")*100 + nodes[i].getAttribute("status")*1;
184 var point = new GLatLng(parseFloat(nodes[i].getAttribute("lat")),
185 parseFloat(nodes[i].getAttribute("lng")));
186 var marker = CreateMarker(point, name, address, type, id);
187 map.addOverlay(marker);
188 LoadedNodes[id]=point;
189 NumAddedNodes = NumAddedNodes + 1;
190 }
191 }
192 document.getElementById("NumNodes").innerHTML = "Nacteno " + NumAddedNodes + " nodu";
193 
194 var links = xml.documentElement.getElementsByTagName("link");
195 for (var i = 0; i < links.length; i++) {
196 var id1 = links[i].getAttribute("id1");
197 var id2 = links[i].getAttribute("id2");
198 //nacteme jen pokud jde o novy link
199 if (! LoadedLinks[id1+"x"+id2] && ! LoadedLinks[id2+"x"+id1]) {
200 var backbone = links[i].getAttribute("backbone");
201 var inplanning = links[i].getAttribute("inplanning");
202 var type = links[i].getAttribute("type");
203 var status = links[i].getAttribute("status");
204 
205 //zobrazi se jen pokud jsou k dispozici oba nody
206 if ( LoadedNodes[id1] && LoadedNodes[id2]) {
2073simandl var LinkSize = (backbone * 2);
2084simandl var LinkColBg = "#000000";
209 var LinkColBgOpacity = 0.2;
210 var LinkColOpacity = 0.6;
211 var LinkStyle = "solid";
212 
213 if (inplanning == 1) {
214 LinkColBgOpacity = 0.1;
2155simandl LinkColOpacity = 0.2;
2164simandl LinkColBg = "#0000FF";
217 LinkStyle = "dash";
218 }
219// DebugPrint(":"+ inplanning + ":");
220 
221 var Linepts = new Array();
222 Linepts = [LoadedNodes[id1],LoadedNodes[id2]];
223 LineLength = Math.round(GetLineLength(Linepts[0].lat(), Linepts[0].lng(), Linepts[1].lat(), Linepts[1].lng()));
224 
2251simandl var polyOptions = {geodesic:false};
2265simandl var polyline = new GPolyline([LoadedNodes[id1],LoadedNodes[id2]], LinkColBg, 3 + LinkSize, LinkColBgOpacity, polyOptions);
227 map.addOverlay(polyline);
2284simandl 
2293simandl var LinkColTypeAct = LinkColTypeNA;
230 if ( LinkColType[type]) {
231 LinkColTypeAct = LinkColType[type];
232 }
2332simandl 
2345simandl LoadedLinks[id1+"x"+id2] = new GPolyline([LoadedNodes[id1],LoadedNodes[id2]], LinkColTypeAct, 1 + LinkSize, LinkColOpacity, polyOptions);
2354simandl map.addOverlay(LoadedLinks[id1+"x"+id2]);
236 
2371simandl NumVisibleLinks = NumVisibleLinks + 1;
238 } else {
239 //zde se pokusime donahrat nod ktery nam chybi
240 
241 
242 NumInVisibleLinks = NumInVisibleLinks + 1;
243 }
244 
2454simandl// LoadedLinks[id1+"x"+id2]=polyline;
246 
2471simandl NumAddedLinks = NumAddedLinks + 1;
248 }
249 }
250 document.getElementById("NumLinks").innerHTML = "Nacteno " + NumAddedLinks + " linku a zobrazeno " + NumVisibleLinks + " linku a " + NumInVisibleLinks + " nezobrazeno.";
251 });
252 }
253 
254 //##############################
2554simandl function GetLineLength(Lat1, Lon1, Lat2, Lon2) {
256 var R = 6371; // km
257 var dLat = (Lat2-Lat1) * Math.PI / 180;
258 var dLon = (Lon2-Lon1) * Math.PI / 180;
259 var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
260 Math.cos(Lat1 * Math.PI / 180) * Math.cos(Lat2 * Math.PI / 180) *
261 Math.sin(dLon/2) * Math.sin(dLon/2);
262 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
263 var LineLength = 1000 * R * c;
264 return LineLength;
265 }
266 
267 //##############################
2681simandl function HandleMapMoveEnd() {
269 if (AutoFetchMode) {
270 ClearOverlayAndData();
271 FetchOverlayAndData();
272 }
273 document.getElementById("status").innerHTML = "Po presunu mame celkem " + NumAddedNodes + " nodu";
274 }
275 
276 //##############################
277 function CreateMarker(point, name, address, type, id) {
278 var marker = new GMarker(point, {draggable: true, bounce: true, icon: NodeIcon[type]});
279 var html = "<b>" + id + " " + name + "</b> <br/>" + address +" <br/>" + type;
280 GEvent.addListener(marker, "dragstart", function() {
281 map.closeInfoWindow();
282 });
2835simandl GEvent.addListener(marker, \'click\', function() {
2841simandl marker.openInfoWindowHtml(html);
285 });
286 return marker;
287 }
288 
289 //##############################
290 function SwitchDatabase(NewDatabase) {
291 CurrentDatabase = NewDatabase;
292 document.getElementById("souradnice").innerHTML = CurrentDatabase;
293 ClearOverlayAndData();
294 FetchOverlayAndData();
295 document.getElementById("status").innerHTML = "Databaze zmenena na "+CurrentDatabase;
296 document.getElementById("databaze").innerHTML = CurrentDatabase;
297 }
298 
299 //##############################
300 function ChangeNodeLimit(NewNodeLimit) {
301 NodeLimit = NewNodeLimit;
302 FetchOverlayAndData();
303 document.getElementById("status").innerHTML = "Limit zmenen na "+NewNodeLimit;
304 }
305 
306 //##############################
3074simandl function DebugPrint(Text) {
308 document.getElementById("debug").innerHTML = document.getElementById("debug").innerHTML + Text;
309 }
310 
311 //##############################
3121simandl function Fetch() {
313 NodeLayer();
314 document.getElementById("status").innerHTML = "Nacteno";
315 }
316 
317 //##############################
318 function FetchOverlayAndData() {
319 if (AutoFetchMode) {
320 Fetch();
321 };
322 }
323 
324 //##############################
325 function ClearOverlayAndData() {
326 if (AutoClearMode) {
327 Clear();
328 };
329 }
330 
331 //##############################
332 function Clear() {
333 document.getElementById("status").innerHTML = "Smazano " + NumAddedNodes + " nodu";
334 map.clearOverlays();
335 LoadedNodes=Array();
336 LoadedLinks=Array();
337 NumAddedNodes=0;
338 document.getElementById("NumNodes").innerHTML = "Nacteno " + NumAddedNodes + " nodu";
339 LoadedLinks=Array();
340 NumAddedLinks=0;
341 NumVisibleLinks=0;
3425simandl NumInVisibleLinks=0;
3431simandl document.getElementById("NumLinks").innerHTML = "Nacteno " + NumAddedLinks + " linku";
344 }
345 
346 //##############################
347 function ToggleAutoFetchMode(NewAutoFetchMode) {
348 AutoFetchMode = NewAutoFetchMode;
349 if (AutoFetchMode) {
350 document.getElementById("status").innerHTML = "Automaticke nacitani zapnuto.";
351 }
352 else {
353 document.getElementById("status").innerHTML = "Automaticke nacitani vypnuto.";
354 }
355 }
356 
357 //##############################
358 function ToggleAutoClearMode(NewAutoClearMode) {
359 AutoClearMode = NewAutoClearMode;
360 if (AutoClearMode) {
361 document.getElementById("status").innerHTML = "Automaticke mazani zapnuto.";
362 }
363 else {
364 document.getElementById("status").innerHTML = "Automaticke mazani vypnuto.";
365 }
366 }
367 
368 </script>
369 </head>
370 
371 <body onload="load()" onunload="GUnload()">
372 <table>
373 <tr>
374 <td>
375 <div id="map" style="width: 800px; height: 600px"></div>
376 </td>
377 
378 <td valign="top">
3795simandl <div id="UserInfo">';
380 
381 echo "Prihlasen jako:<br>";
382 echo $bbuserinfo['username']."&nbsp;";
383 echo $bbuserinfo['userid']."&nbsp;";
384 echo $bbuserinfo['mapperms']."&nbsp;";
385 echo $_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']."&nbsp;";
386 
387 echo '</div>
3881simandl Prepnout databazi:
389 <div id="databaze">0</div>
3905simandl <input type="button" value="ajax" onClick="SwitchDatabase(\'ajax\');"/>
391 <input type="button" value="czfmutf" onClick="SwitchDatabase(\'czfmutf\');"/>
392 <input type="button" value="gendb" onClick="SwitchDatabase(\'gendb\');"/>
3931simandl <br>
394 <div id="NumNodes">0</div>
395 <div id="NumLinks">0</div>
396 <input type="button" value="Nacist ted" onClick="Fetch();"/>
397 <input type="button" value="Smazat ted" onClick="Clear();"/>
398 <br>
399 Automaticke nacitani:
400 <input id="AutoFetchModeCheckButton" type="checkBox" onclick="ToggleAutoFetchMode(this.checked)">
401 <br>
402 Automaticke mazani:
403 <input id="AutoClearModeCheckButton" type="checkBox" onclick="ToggleAutoClearMode(this.checked)">
404 <br>
405 Limit nodu:
406 <select id="NodeLimitSelectBox" onchange="ChangeNodeLimit(this.value)">
407 <option value="0">0</option>
408 <option value="30" selected="selected">30</option>
409 <option value="60">60</option>
410 <option value="200">200</option>
411 <option value="500">500</option>
412 <option value="1000">1000</option>
413 </select>
4143simandl 
4151simandl </td>
416 </tr>
417 
418 <tr>
419 <td colspan=2>
420 
4214simandl <div id="debug"></div>
4221simandl <div id="status">Hotovo!</div>
423 <div id="data"></div>
4242simandl <div id="NodeCoordinates">aaa</div>
4251simandl <div id="souradnice">Souradnice stredu:<br>Rozsah:<br>Zvetseni:</div>
4264simandl <a href="http://code.google.com/apis/maps/documentation/examples/">http://code.google.com/apis/maps/documentation/examples/</a>
4271simandl <br>
4284simandl <a href="http://code.google.com/apis/kml/documentation/kml_tut.html">http://code.google.com/apis/kml/documentation/kml_tut.html</a>
429 <br>
430 <a href="http://mapki.com/wiki/Knowledge_Base">http://mapki.com/wiki/Knowledge_Base</a>
431 <br>
432 <a href="http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm">http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm</a>
433 <br>
4345simandl http://www.czfree.net/forum/showthread.php?postid=197732#post197732
4351simandl </td>
436 </tr>
437 
438 <tr>
439 <td colspan=2>
440 <br>
441 CZFGmap (c) Petr Simandl - GNU General Public License
442 <br>
443 <a href="http://websvn.prosek.czf/">websvn.prosek.czf</a>
444 </td>
445 </tr>
446 
447 </table>
448 
449 </body>
450</html>
4515simandl';
452?>

Powered by WebSVN 2.2.1