1 | 5 | simandl | <?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 | | | |
18 | | | error_reporting(7); |
19 | | | |
20 | | | include("../forum/globalmap.php"); |
21 | | | |
22 | | | switch (@$_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 | | | |
33 | | | echo ' |
34 | 1 | simandl | <!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"/> |
40 | 3 | simandl | <title>CZFGmap</title> |
41 | 1 | simandl | <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> |
51 | 5 | simandl | <script src="http://maps.google.com/maps?file=api&v=2&key='.$GMapKey.'" |
52 | 1 | simandl | type="text/javascript"></script> |
53 | | | <script src="http://www.google.com/uds/api?file=uds.js&v=1.0" type="text/javascript"></script> |
54 | 9 | simandl | <script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script> |
55 | 1 | simandl | <script type="text/javascript"> |
56 | | | |
57 | 9 | simandl | //<![CDATA[ |
58 | | | |
59 | 1 | simandl | //### Globalni promenne ################################# |
60 | | | var CurrentDatabase = "czfmutf"; |
61 | | | var NodeLimit = "200"; |
62 | | | var NodeOrder = "ASC"; |
63 | | | var NodeSortBy = "name"; |
64 | | | var Where = ""; |
65 | | | var LoadedNodes = new Array(); |
66 | 9 | simandl | var LoadedLinks = new Array(); |
67 | 1 | simandl | var map; |
68 | 8 | simandl | var NodeIcon = new Array(); |
69 | | | var DatabaseNodeTables = new Array(); |
70 | 1 | simandl | var AutoFetchMode = true; |
71 | | | var AutoClearMode = true; |
72 | | | var NumLoadedNodes = 0; |
73 | | | var NumAddedNodes = 0; |
74 | | | var NumLoadedLinks = 0; |
75 | | | var NumAddedLinks = 0; |
76 | | | var NumVisibleLinks = 0; |
77 | | | var NumInVisibleLinks = 0; |
78 | 8 | simandl | var PtA = new Array(); |
79 | | | var PtB = new Array(); |
80 | | | var PtC = new Array(); |
81 | | | var PtPt = 1; |
82 | | | var PtNum = 0; |
83 | 9 | simandl | |
84 | | | var MapSizeX = 800; |
85 | | | var MapSizeY = 600; |
86 | | | var MapCenterLat = 50.123567; |
87 | | | var MapCenterLon = 14.496258; |
88 | | | var MapZoom = 15; |
89 | | | var MapName = "Mapa"; |
90 | | | var saved=[]; |
91 | 3 | simandl | |
92 | 8 | simandl | var LinkColType = new Array(); |
93 | 4 | simandl | LinkColType["00000001"] = "#00aa00"; |
94 | 3 | simandl | LinkColType["00000001"] = "#00FF00"; |
95 | | | var LinkColTypeWifiBackbone = "#fafa00"; |
96 | | | LinkColType["00000002"] = "#be0000"; |
97 | | | LinkColType["00000006"] = "#ff5050"; |
98 | | | LinkColType["00000003"] = "#64c8ff"; |
99 | | | LinkColType["00000004"] = "#dc00dc"; |
100 | | | LinkColType["00000007"] = "#c8c8c8"; |
101 | | | LinkColType["00000008"] = "#ffffff"; |
102 | | | LinkColType["00000009"] = "#fa8000"; |
103 | | | LinkColType["00000099"] = "#0000fa"; |
104 | | | var LinkColTypeNA = "#78783c"; |
105 | | | LinkColType["00000005"] = "#00fafa"; |
106 | 1 | simandl | |
107 | | | //nacteni ikon pro nody |
108 | | | var NodeType = [0,1,9,10,98,99]; |
109 | | | var NodeState = [1,9,10,40,79,80,90]; |
110 | | | for (type in NodeType) { |
111 | | | for (state in NodeState) { |
112 | | | i = 10000 + NodeType[type]*100 + NodeState[state]; |
113 | | | NodeIcon[i] = new GIcon(); |
114 | 5 | simandl | NodeIcon[i].image = "./images/node/node-" + NodeType[type] + "-" + NodeState[state] + ".png"; |
115 | 1 | simandl | NodeIcon[i].iconSize = new GSize(15,15); |
116 | | | NodeIcon[i].iconAnchor = new GPoint(7,7); |
117 | | | NodeIcon[i].shadowSize = new GSize(22,20); |
118 | | | NodeIcon[i].infoWindowAnchor = new GPoint(5,1); |
119 | | | } |
120 | | | } |
121 | | | |
122 | | | //### Uvodni funkce ################################# |
123 | | | function load() { |
124 | 9 | simandl | MapLoad(); |
125 | | | LoadSettings(); |
126 | | | } |
127 | | | |
128 | | | function MapLoad() { |
129 | 1 | simandl | if (GBrowserIsCompatible()) { |
130 | 5 | simandl | map = new GMap2(document.getElementById("map"),{draggableCursor: \'crosshair\', draggingCursor: \'pointer\'}); |
131 | 9 | simandl | |
132 | | | |
133 | 1 | simandl | map.addControl(new GLargeMapControl()); |
134 | | | map.addControl(new GMapTypeControl()); |
135 | 9 | simandl | var MapCenter = new GLatLng(MapCenterLat, MapCenterLon); |
136 | | | map.setCenter(MapCenter, MapZoom); |
137 | 1 | simandl | map.enableScrollWheelZoom(); |
138 | | | map.addControl(new GScaleControl()); |
139 | 9 | simandl | map.addControl(new MDControl()); |
140 | | | |
141 | | | // Selecting map type |
142 | | | var MapTypes = map.getMapTypes(); |
143 | | | for(var i = 0; i < MapTypes.length; i++) { |
144 | | | if (MapName == MapTypes[i].getName()) map.setMapType(MapTypes[i]); |
145 | | | } |
146 | | | |
147 | | | map.addControl(new GOverviewMapControl()); |
148 | 1 | simandl | |
149 | | | map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,20))); |
150 | | | //tohle zajisti znovunacteni nodu po presunu |
151 | | | GEvent.addListener(map, "moveend", HandleMapMoveEnd); |
152 | | | |
153 | 2 | simandl | //ziskani souradnic po kliknuti |
154 | 8 | simandl | GEvent.addListener(map, \'click\', function(overlay, point) { if(point) { HandleNextPoint(point) }} ); |
155 | 2 | simandl | |
156 | 1 | simandl | //tohle zajisti vypis pri startu |
157 | | | var center = map.getCenter(); |
158 | 9 | simandl | document.getElementById("SouradniceStredu").innerHTML = CurrentDatabase + "<br>Souradnice stredu:" + center.toString() + "<br>Rozsah: " + map.getBounds()+"<br>Zvetseni: " + map.getZoom(); |
159 | 1 | simandl | |
160 | | | //tohle zajisti prubezny vypis |
161 | | | GEvent.addListener(map, "moveend", function() { |
162 | | | var center = map.getCenter(); |
163 | 9 | simandl | document.getElementById("SouradniceStredu").innerHTML = CurrentDatabase + " " + map.getBounds().getSouthWest().lat() + "<br>Souradnice stredu: " + center.toString() + "<br>Rozsah: " + map.getBounds()+"<br>Zvetseni: " + map.getZoom(); |
164 | 1 | simandl | }); |
165 | | | } |
166 | | | } |
167 | | | |
168 | | | //### Ostatni funkce ########################### |
169 | | | |
170 | | | function NodeLayer() { |
171 | | | //body se berou z databaze pomoci php skriptu ktery dela jen inteface a generuje xml |
172 | | | Where = ""; |
173 | | | GDownloadUrl("mapa_genxml.php?db="+CurrentDatabase |
174 | | | +"&latmin="+map.getBounds().getSouthWest().lat() |
175 | | | +"&latmax="+map.getBounds().getNorthEast().lat() |
176 | | | +"&lonmin="+map.getBounds().getSouthWest().lng() |
177 | | | +"&lonmax="+map.getBounds().getNorthEast().lng() |
178 | | | +"&sortby="+NodeSortBy |
179 | | | +"&limit="+NodeLimit |
180 | | | +"&order="+NodeOrder |
181 | | | +"&where="+Where |
182 | | | +"&zoom="+map.getZoom() |
183 | | | , function(data) { |
184 | | | var xml = GXml.parse(data); |
185 | | | var nodes = xml.documentElement.getElementsByTagName("node"); |
186 | | | for (var i = 0; i < nodes.length; i++) { |
187 | | | var id = nodes[i].getAttribute("id"); |
188 | | | //zobrazime jen nove nody |
189 | | | if (! LoadedNodes[id]) { |
190 | | | var name = nodes[i].getAttribute("name"); |
191 | | | var address = nodes[i].getAttribute("address"); |
192 | | | var type = 10000 + nodes[i].getAttribute("type")*100 + nodes[i].getAttribute("status")*1; |
193 | | | var point = new GLatLng(parseFloat(nodes[i].getAttribute("lat")), |
194 | | | parseFloat(nodes[i].getAttribute("lng"))); |
195 | | | var marker = CreateMarker(point, name, address, type, id); |
196 | | | map.addOverlay(marker); |
197 | | | LoadedNodes[id]=point; |
198 | | | NumAddedNodes = NumAddedNodes + 1; |
199 | | | } |
200 | | | } |
201 | | | document.getElementById("NumNodes").innerHTML = "Nacteno " + NumAddedNodes + " nodu"; |
202 | | | |
203 | | | var links = xml.documentElement.getElementsByTagName("link"); |
204 | | | for (var i = 0; i < links.length; i++) { |
205 | | | var id1 = links[i].getAttribute("id1"); |
206 | | | var id2 = links[i].getAttribute("id2"); |
207 | | | //nacteme jen pokud jde o novy link |
208 | | | if (! LoadedLinks[id1+"x"+id2] && ! LoadedLinks[id2+"x"+id1]) { |
209 | | | var backbone = links[i].getAttribute("backbone"); |
210 | | | var inplanning = links[i].getAttribute("inplanning"); |
211 | | | var type = links[i].getAttribute("type"); |
212 | | | var status = links[i].getAttribute("status"); |
213 | | | |
214 | | | //zobrazi se jen pokud jsou k dispozici oba nody |
215 | | | if ( LoadedNodes[id1] && LoadedNodes[id2]) { |
216 | 3 | simandl | var LinkSize = (backbone * 2); |
217 | 4 | simandl | var LinkColBg = "#000000"; |
218 | 6 | simandl | var LinkColBgOpacity = 1; |
219 | | | var LinkColOpacity = 1; |
220 | 4 | simandl | var LinkStyle = "solid"; |
221 | | | |
222 | | | if (inplanning == 1) { |
223 | | | LinkColBgOpacity = 0.1; |
224 | 5 | simandl | LinkColOpacity = 0.2; |
225 | 4 | simandl | LinkColBg = "#0000FF"; |
226 | | | LinkStyle = "dash"; |
227 | | | } |
228 | | | // DebugPrint(":"+ inplanning + ":"); |
229 | | | |
230 | 1 | simandl | var polyOptions = {geodesic:false}; |
231 | 5 | simandl | var polyline = new GPolyline([LoadedNodes[id1],LoadedNodes[id2]], LinkColBg, 3 + LinkSize, LinkColBgOpacity, polyOptions); |
232 | | | map.addOverlay(polyline); |
233 | 4 | simandl | |
234 | 3 | simandl | var LinkColTypeAct = LinkColTypeNA; |
235 | | | if ( LinkColType[type]) { |
236 | | | LinkColTypeAct = LinkColType[type]; |
237 | | | } |
238 | 2 | simandl | |
239 | 5 | simandl | LoadedLinks[id1+"x"+id2] = new GPolyline([LoadedNodes[id1],LoadedNodes[id2]], LinkColTypeAct, 1 + LinkSize, LinkColOpacity, polyOptions); |
240 | 4 | simandl | map.addOverlay(LoadedLinks[id1+"x"+id2]); |
241 | | | |
242 | 1 | simandl | NumVisibleLinks = NumVisibleLinks + 1; |
243 | | | } else { |
244 | | | //zde se pokusime donahrat nod ktery nam chybi |
245 | | | |
246 | | | |
247 | | | NumInVisibleLinks = NumInVisibleLinks + 1; |
248 | | | } |
249 | | | |
250 | 4 | simandl | // LoadedLinks[id1+"x"+id2]=polyline; |
251 | | | |
252 | 1 | simandl | NumAddedLinks = NumAddedLinks + 1; |
253 | | | } |
254 | | | } |
255 | | | document.getElementById("NumLinks").innerHTML = "Nacteno " + NumAddedLinks + " linku a zobrazeno " + NumVisibleLinks + " linku a " + NumInVisibleLinks + " nezobrazeno."; |
256 | | | }); |
257 | | | } |
258 | | | |
259 | | | //############################## |
260 | 8 | simandl | function HandleNextPoint(point) { |
261 | | | |
262 | | | document.getElementById("NodeCoordinates").innerHTML = (point.y.toFixed(6)+\'x\'+point.x.toFixed(6)); |
263 | | | |
264 | | | if ( PtPt == 1 ) { |
265 | | | document.getElementById("NodeCoordinatesA").innerHTML = (\'A \'+point.y.toFixed(6)+\'x\'+point.x.toFixed(6)); |
266 | | | PtA = point; |
267 | | | } |
268 | | | if ( PtPt == 2 ) { |
269 | | | document.getElementById("NodeCoordinatesB").innerHTML = (\'B \'+point.y.toFixed(6)+\'x\'+point.x.toFixed(6)); |
270 | | | PtB = point; |
271 | | | } |
272 | | | if ( PtPt == 3 ) { |
273 | | | document.getElementById("NodeCoordinatesC").innerHTML = (\'C \'+point.y.toFixed(6)+\'x\'+point.x.toFixed(6)); |
274 | | | PtC = point; |
275 | | | } |
276 | | | |
277 | | | |
278 | | | PtPt = PtPt + 1; |
279 | | | if ( PtPt > 3 ) { PtPt = 1; } |
280 | | | PtNum = PtNum + 1; |
281 | | | |
282 | | | if ( PtNum > 1 ) { |
283 | 9 | simandl | var DistanceAB = Math.round(GetLineLength(PtA, PtB)); |
284 | | | document.getElementById("NodeDistanceAB").innerHTML = DistanceAB+\'m\'; |
285 | | | document.getElementById("NodeDistanceBA").innerHTML = DistanceAB+\'m\'; |
286 | 8 | simandl | } |
287 | | | if ( PtNum > 2 ) { |
288 | 9 | simandl | var DistanceBC = Math.round(GetLineLength(PtC, PtB)); |
289 | | | document.getElementById("NodeDistanceBC").innerHTML = DistanceBC+\'m\'; |
290 | | | document.getElementById("NodeDistanceCB").innerHTML = DistanceBC+\'m\'; |
291 | | | var DistanceAC = Math.round(GetLineLength(PtC, PtA)); |
292 | | | document.getElementById("NodeDistanceAC").innerHTML = DistanceAC+\'m\'; |
293 | | | document.getElementById("NodeDistanceCA").innerHTML = DistanceAC+\'m\'; |
294 | 8 | simandl | |
295 | 9 | simandl | document.getElementById("NodeAngleACB").innerHTML = Math.round(GetAngle(PtA, PtC, PtB))+\'st\'; |
296 | | | document.getElementById("NodeAngleBAC").innerHTML = Math.round(GetAngle(PtB, PtC, PtA))+\'st\'; |
297 | | | document.getElementById("NodeAngleCBA").innerHTML = Math.round(GetAngle(PtC, PtA, PtB))+\'st\'; |
298 | | | |
299 | | | document.getElementById("NodeDistanceBAC").innerHTML = ( DistanceAB + DistanceAC ) +\'m\'; |
300 | | | document.getElementById("NodeDistanceABC").innerHTML = ( DistanceAB + DistanceBC ) +\'m\'; |
301 | | | document.getElementById("NodeDistanceBCA").innerHTML = ( DistanceBC + DistanceAC ) +\'m\'; |
302 | 8 | simandl | } |
303 | 9 | simandl | } |
304 | 8 | simandl | |
305 | 9 | simandl | //############################## |
306 | | | function GetAngle(PA, PB, PC) { |
307 | | | var a = GetLineLength(PC, PB); |
308 | | | var b = GetLineLength(PC, PA); |
309 | | | var c = GetLineLength(PA, PB); |
310 | | | var s = ( a + b + c ) / 2; |
311 | | | var alfa = (360/Math.PI)*Math.asin(Math.sqrt((s-b)*(s-c)/(b*c))); |
312 | | | return alfa; |
313 | 8 | simandl | } |
314 | | | |
315 | | | //############################## |
316 | 9 | simandl | function GetLineLength(PA, PB) { |
317 | | | var Lat1 = PA.lat(); |
318 | | | var Lon1 = PA.lng(); |
319 | | | var Lat2 = PB.lat(); |
320 | | | var Lon2 = PB.lng(); |
321 | 4 | simandl | var R = 6371; // km |
322 | | | var dLat = (Lat2-Lat1) * Math.PI / 180; |
323 | | | var dLon = (Lon2-Lon1) * Math.PI / 180; |
324 | | | var a = Math.sin(dLat/2) * Math.sin(dLat/2) + |
325 | | | Math.cos(Lat1 * Math.PI / 180) * Math.cos(Lat2 * Math.PI / 180) * |
326 | | | Math.sin(dLon/2) * Math.sin(dLon/2); |
327 | | | var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); |
328 | | | var LineLength = 1000 * R * c; |
329 | | | return LineLength; |
330 | | | } |
331 | | | |
332 | | | //############################## |
333 | 1 | simandl | function HandleMapMoveEnd() { |
334 | | | if (AutoFetchMode) { |
335 | | | ClearOverlayAndData(); |
336 | | | FetchOverlayAndData(); |
337 | | | } |
338 | | | document.getElementById("status").innerHTML = "Po presunu mame celkem " + NumAddedNodes + " nodu"; |
339 | | | } |
340 | | | |
341 | | | //############################## |
342 | | | function CreateMarker(point, name, address, type, id) { |
343 | | | var marker = new GMarker(point, {draggable: true, bounce: true, icon: NodeIcon[type]}); |
344 | | | var html = "<b>" + id + " " + name + "</b> <br/>" + address +" <br/>" + type; |
345 | | | GEvent.addListener(marker, "dragstart", function() { |
346 | | | map.closeInfoWindow(); |
347 | | | }); |
348 | 5 | simandl | GEvent.addListener(marker, \'click\', function() { |
349 | 1 | simandl | marker.openInfoWindowHtml(html); |
350 | | | }); |
351 | | | return marker; |
352 | | | } |
353 | | | |
354 | | | //############################## |
355 | | | function SwitchDatabase(NewDatabase) { |
356 | | | CurrentDatabase = NewDatabase; |
357 | 9 | simandl | document.getElementById("SouradniceStredu").innerHTML = CurrentDatabase; |
358 | 1 | simandl | ClearOverlayAndData(); |
359 | | | FetchOverlayAndData(); |
360 | | | document.getElementById("status").innerHTML = "Databaze zmenena na "+CurrentDatabase; |
361 | | | document.getElementById("databaze").innerHTML = CurrentDatabase; |
362 | | | } |
363 | | | |
364 | | | //############################## |
365 | | | function ChangeNodeLimit(NewNodeLimit) { |
366 | | | NodeLimit = NewNodeLimit; |
367 | | | FetchOverlayAndData(); |
368 | | | document.getElementById("status").innerHTML = "Limit zmenen na "+NewNodeLimit; |
369 | 9 | simandl | document.getElementById("NodeLimitSelectBox").value = NodeLimit; |
370 | 1 | simandl | } |
371 | | | |
372 | | | //############################## |
373 | 9 | simandl | function ChangeMapSizeX(NewMapSizeX) { |
374 | | | MapSizeX = NewMapSizeX; |
375 | | | FetchOverlayAndData(); |
376 | | | document.getElementById("status").innerHTML = "Rozmer X zmenen na "+MapSizeX; |
377 | | | document.getElementById("map").style.width = MapSizeX+"px"; |
378 | | | |
379 | | | ClearOverlayAndData(); |
380 | | | MapLoad(); |
381 | | | FetchOverlayAndData(); |
382 | | | } |
383 | | | |
384 | | | //############################## |
385 | | | function ChangeMapSizeY(NewMapSizeY) { |
386 | | | MapSizeY = NewMapSizeY; |
387 | | | FetchOverlayAndData(); |
388 | | | document.getElementById("status").innerHTML = "Rozmer Y zmenen na "+MapSizeY; |
389 | | | document.getElementById("map").style.height = MapSizeY+"px"; |
390 | | | |
391 | | | ClearOverlayAndData(); |
392 | | | MapLoad(); |
393 | | | FetchOverlayAndData(); |
394 | | | } |
395 | | | |
396 | | | //############################## |
397 | 4 | simandl | function DebugPrint(Text) { |
398 | | | document.getElementById("debug").innerHTML = document.getElementById("debug").innerHTML + Text; |
399 | | | } |
400 | | | |
401 | | | //############################## |
402 | 1 | simandl | function Fetch() { |
403 | | | NodeLayer(); |
404 | | | document.getElementById("status").innerHTML = "Nacteno"; |
405 | | | } |
406 | | | |
407 | | | //############################## |
408 | | | function FetchOverlayAndData() { |
409 | | | if (AutoFetchMode) { |
410 | | | Fetch(); |
411 | | | }; |
412 | | | } |
413 | | | |
414 | | | //############################## |
415 | | | function ClearOverlayAndData() { |
416 | | | if (AutoClearMode) { |
417 | 9 | simandl | ForceClear(); |
418 | 1 | simandl | }; |
419 | | | } |
420 | | | |
421 | | | //############################## |
422 | 9 | simandl | function ForceClear() { |
423 | 1 | simandl | document.getElementById("status").innerHTML = "Smazano " + NumAddedNodes + " nodu"; |
424 | | | map.clearOverlays(); |
425 | | | LoadedNodes=Array(); |
426 | | | LoadedLinks=Array(); |
427 | | | NumAddedNodes=0; |
428 | | | document.getElementById("NumNodes").innerHTML = "Nacteno " + NumAddedNodes + " nodu"; |
429 | | | NumAddedLinks=0; |
430 | | | NumVisibleLinks=0; |
431 | 5 | simandl | NumInVisibleLinks=0; |
432 | 1 | simandl | document.getElementById("NumLinks").innerHTML = "Nacteno " + NumAddedLinks + " linku"; |
433 | | | } |
434 | | | |
435 | | | //############################## |
436 | | | function ToggleAutoFetchMode(NewAutoFetchMode) { |
437 | | | AutoFetchMode = NewAutoFetchMode; |
438 | | | if (AutoFetchMode) { |
439 | | | document.getElementById("status").innerHTML = "Automaticke nacitani zapnuto."; |
440 | | | } |
441 | | | else { |
442 | | | document.getElementById("status").innerHTML = "Automaticke nacitani vypnuto."; |
443 | | | } |
444 | 9 | simandl | document.getElementById("AutoFetchModeCheckButton").checked = AutoFetchMode; |
445 | 1 | simandl | } |
446 | | | |
447 | | | //############################## |
448 | | | function ToggleAutoClearMode(NewAutoClearMode) { |
449 | | | AutoClearMode = NewAutoClearMode; |
450 | | | if (AutoClearMode) { |
451 | | | document.getElementById("status").innerHTML = "Automaticke mazani zapnuto."; |
452 | | | } |
453 | | | else { |
454 | | | document.getElementById("status").innerHTML = "Automaticke mazani vypnuto."; |
455 | 9 | simandl | } |
456 | | | document.getElementById("AutoClearModeCheckButton").checked = AutoClearMode; |
457 | 1 | simandl | } |
458 | | | |
459 | 9 | simandl | //############################## |
460 | | | function SetCookie(Name, Data, Validity) { |
461 | | | var Day = 24 * 3600 * 1000; |
462 | | | var Expiration = new Date(); |
463 | | | Expiration.setTime(Expiration.getTime() + Validity * Day); |
464 | | | document.cookie = Name + "=" + escape(Data) + "; expires=" + Expiration.toGMTString() + "; path=/"; |
465 | | | } |
466 | | | |
467 | | | //############################## |
468 | | | function GetCookie(Name) { |
469 | | | var Prefix = Name + "="; |
470 | | | var Begin = document.cookie.indexOf(Prefix); |
471 | | | if ( Begin == -1 ) |
472 | | | return ""; |
473 | | | Begin += Prefix.length; |
474 | | | if ( Begin >= document.cookie.length ) |
475 | | | return ""; |
476 | | | var End = document.cookie.indexOf(";", Begin); |
477 | | | if ( End == -1 ) |
478 | | | End = document.cookie.length; |
479 | | | return unescape(document.cookie.substring(Begin, End)); |
480 | | | } |
481 | | | |
482 | | | //############################## |
483 | | | function SaveSettingsCookieText() { |
484 | | | var Text = "db=" + CurrentDatabase |
485 | | | + "&map=" + map.getCurrentMapType().getName() |
486 | | | + "&sizex=" + MapSizeX |
487 | | | + "&sizey=" + MapSizeY |
488 | | | + "&lat=" + map.getCenter().lat() |
489 | | | + "&lon=" + map.getCenter().lng() |
490 | | | + "&zoom=" + map.getZoom() |
491 | | | + "&autofetch=" + AutoFetchMode |
492 | | | + "&autoclear=" + AutoClearMode |
493 | | | + "&nodelimit=" + NodeLimit |
494 | | | + "&"; |
495 | | | return Text; |
496 | | | } |
497 | | | |
498 | | | //############################## |
499 | | | function LoadSettings() { |
500 | | | var Text = GetCookie("default"); |
501 | | | var Begin = 0; |
502 | | | var End = 0; |
503 | | | |
504 | | | End = Text.indexOf("&",Begin); |
505 | | | while (End > -1) { |
506 | | | var Parameter = Text.substring(Begin,End); |
507 | | | var EqualPosition = Parameter.indexOf("="); |
508 | | | if ((EqualPosition > -1) && (EqualPosition < Parameter.length)) { |
509 | | | var ParameterName = Parameter.substring(0,EqualPosition); |
510 | | | var ParameterValue = Parameter.substring(EqualPosition+1,Parameter.length); |
511 | | | if (ParameterName == "db") CurrentDatabase = ParameterValue; |
512 | | | if (ParameterName == "map") MapName = ParameterValue; |
513 | | | if (ParameterName == "sizex") MapSizeX = 1*ParameterValue; |
514 | | | if (ParameterName == "sizey") MapSizeY = 1*ParameterValue; |
515 | | | if (ParameterName == "lat") MapCenterLat = 1*ParameterValue; |
516 | | | if (ParameterName == "lon") MapCenterLon = 1*ParameterValue; |
517 | | | if (ParameterName == "zoom") MapZoom = 1*ParameterValue; |
518 | | | if ((ParameterName == "autofetch") && ParameterValue == "true" ) ToggleAutoFetchMode(true); |
519 | | | if ((ParameterName == "autofetch") && ParameterValue == "false" ) ToggleAutoFetchMode(false); |
520 | | | if ((ParameterName == "autoclear") && ParameterValue == "true" ) ToggleAutoClearMode(true); |
521 | | | if ((ParameterName == "autoclear") && ParameterValue == "false" ) ToggleAutoClearMode(false); |
522 | | | if (ParameterName == "nodelimit") ChangeNodeLimit(ParameterValue); |
523 | | | } |
524 | | | Begin = End + 1; |
525 | | | End = Text.indexOf("&",Begin); |
526 | | | } |
527 | | | |
528 | | | document.getElementById("AutoFetchModeCheckButton").checked = AutoFetchMode; |
529 | | | document.getElementById("AutoClearModeCheckButton").checked = AutoClearMode; |
530 | | | document.getElementById("NodeLimitSelectBox").value = NodeLimit; |
531 | | | document.getElementById("databaze").innerHTML = CurrentDatabase; |
532 | | | |
533 | | | document.getElementById("MapSizeXSelectBox").value = MapSizeX; |
534 | | | document.getElementById("MapSizeYSelectBox").value = MapSizeY; |
535 | | | document.getElementById("map").style.width = MapSizeX+"px"; |
536 | | | document.getElementById("map").style.height = MapSizeY+"px"; |
537 | | | ForceClear(); |
538 | | | MapLoad(); |
539 | | | FetchOverlayAndData(); |
540 | | | } |
541 | | | |
542 | | | //############################## |
543 | | | function MDControl() { } |
544 | | | MDControl.prototype = new GControl(); |
545 | | | MDControl.prototype.initialize = function(map) { |
546 | | | var container = document.createElement("div"); |
547 | | | var savepos= document.createElement("div"); |
548 | | | savepos.title= "Save actual position and zoomlevel"; |
549 | | | savepos.className= "MDbuttons"; |
550 | | | container.appendChild(savepos); |
551 | | | savepos.appendChild(document.createTextNode("Save Position")); |
552 | | | GEvent.addDomListener(savepos, "click", function() { |
553 | | | var center = map.getCenter(); var zoom = map.getZoom(); |
554 | | | saved.splice(0,2,center,zoom); |
555 | | | // alert("Saved Position: "+center.toUrlValue()+"\nZoomlevel: "+zoom); |
556 | | | }); |
557 | | | |
558 | | | var tosaved=document.createElement("div"); |
559 | | | tosaved.title= "Back to saved position"; |
560 | | | tosaved.className= "MDbuttons"; |
561 | | | container.appendChild(tosaved); |
562 | | | tosaved.appendChild(document.createTextNode("To Saved")); |
563 | | | GEvent.addDomListener(tosaved, "click", function() { |
564 | | | if(saved.length > 0) { map.setZoom(saved[1]); map.panTo(saved[0]); } |
565 | | | }); |
566 | | | map.getContainer().appendChild(container); |
567 | | | return container; |
568 | | | } |
569 | | | |
570 | | | MDControl.prototype.getDefaultPosition = function() { |
571 | | | return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7,31)); |
572 | | | } |
573 | | | |
574 | | | |
575 | | | //]]> |
576 | | | </script> |
577 | 1 | simandl | </head> |
578 | | | |
579 | | | <body onload="load()" onunload="GUnload()"> |
580 | | | <table> |
581 | | | <tr> |
582 | | | <td> |
583 | 9 | simandl | <div id="map" class="gmaparea"></div> |
584 | 1 | simandl | </td> |
585 | | | |
586 | 9 | simandl | <td valign="top" class="controlarea"> |
587 | 5 | simandl | <div id="UserInfo">'; |
588 | | | |
589 | | | echo "Prihlasen jako:<br>"; |
590 | | | echo $bbuserinfo['username']." "; |
591 | | | echo $bbuserinfo['userid']." "; |
592 | | | echo $bbuserinfo['mapperms']." "; |
593 | | | echo $_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']." "; |
594 | | | |
595 | | | echo '</div> |
596 | 1 | simandl | Prepnout databazi: |
597 | | | <div id="databaze">0</div> |
598 | 5 | simandl | <input type="button" value="ajax" onClick="SwitchDatabase(\'ajax\');"/> |
599 | | | <input type="button" value="czfmutf" onClick="SwitchDatabase(\'czfmutf\');"/> |
600 | | | <input type="button" value="gendb" onClick="SwitchDatabase(\'gendb\');"/> |
601 | 1 | simandl | <br> |
602 | | | <div id="NumNodes">0</div> |
603 | | | <div id="NumLinks">0</div> |
604 | | | <input type="button" value="Nacist ted" onClick="Fetch();"/> |
605 | 9 | simandl | <input type="button" value="Smazat ted" onClick="ForceClear();"/> |
606 | 1 | simandl | <br> |
607 | | | Automaticke nacitani: |
608 | | | <input id="AutoFetchModeCheckButton" type="checkBox" onclick="ToggleAutoFetchMode(this.checked)"> |
609 | | | <br> |
610 | | | Automaticke mazani: |
611 | | | <input id="AutoClearModeCheckButton" type="checkBox" onclick="ToggleAutoClearMode(this.checked)"> |
612 | | | <br> |
613 | | | Limit nodu: |
614 | | | <select id="NodeLimitSelectBox" onchange="ChangeNodeLimit(this.value)"> |
615 | | | <option value="0">0</option> |
616 | | | <option value="30" selected="selected">30</option> |
617 | | | <option value="60">60</option> |
618 | | | <option value="200">200</option> |
619 | | | <option value="500">500</option> |
620 | | | <option value="1000">1000</option> |
621 | | | </select> |
622 | 3 | simandl | |
623 | 9 | simandl | <input type="button" value=\'Save settings\' onclick=\'SetCookie("default", SaveSettingsCookieText() , 365);\'> |
624 | | | <input type="button" value=\'Load settings\' onclick=\'LoadSettings();\'> |
625 | | | <div> |
626 | | | <select id="MapSizeXSelectBox" onchange="ChangeMapSizeX(this.value)"> |
627 | | | <option value="800" selected="selected">800</option> |
628 | | | <option value="900">900</option> |
629 | | | <option value="1000">1000</option> |
630 | | | <option value="1100">1100</option> |
631 | | | <option value="1200">1200</option> |
632 | | | <option value="1300">1300</option> |
633 | | | <option value="1400">1400</option> |
634 | | | </select> |
635 | | | X |
636 | | | <select id="MapSizeYSelectBox" onchange="ChangeMapSizeY(this.value)"> |
637 | | | <option value="600" selected="selected">600</option> |
638 | | | <option value="700">700</option> |
639 | | | <option value="800">800</option> |
640 | | | <option value="900">900</option> |
641 | | | <option value="1000">1000</option> |
642 | | | </select> |
643 | | | </div> |
644 | | | |
645 | 1 | simandl | </td> |
646 | | | </tr> |
647 | | | |
648 | | | <tr> |
649 | 9 | simandl | <td class="statusarea" > |
650 | 1 | simandl | |
651 | 4 | simandl | <div id="debug"></div> |
652 | 1 | simandl | <div id="status">Hotovo!</div> |
653 | | | <div id="data"></div> |
654 | 2 | simandl | <div id="NodeCoordinates">aaa</div> |
655 | 9 | simandl | <div id="SouradniceStredu">Souradnice stredu:<br>Rozsah:<br>Zvetseni:</div> |
656 | 4 | simandl | <a href="http://code.google.com/apis/maps/documentation/examples/">http://code.google.com/apis/maps/documentation/examples/</a> |
657 | 1 | simandl | <br> |
658 | 4 | simandl | <a href="http://code.google.com/apis/kml/documentation/kml_tut.html">http://code.google.com/apis/kml/documentation/kml_tut.html</a> |
659 | | | <br> |
660 | | | <a href="http://mapki.com/wiki/Knowledge_Base">http://mapki.com/wiki/Knowledge_Base</a> |
661 | | | <br> |
662 | | | <a href="http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm">http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm</a> |
663 | | | <br> |
664 | 5 | simandl | http://www.czfree.net/forum/showthread.php?postid=197732#post197732 |
665 | 9 | simandl | <td> |
666 | | | <table border="1"> |
667 | | | <tr> |
668 | | | <td>Mereni vzdalenosti a uhlu</td><td>A</td><td>B</td><td>C</td> |
669 | | | </tr> |
670 | | | <tr> |
671 | | | <td><div id="NodeCoordinatesA">A klikni na mapu</div></td><td><div id="NodeAngleACB">ACB</div></td> |
672 | | | <td><div id="NodeDistanceAB">AB</div></td><td><div id="NodeDistanceAC">AC</div></td> |
673 | | | </tr> |
674 | | | <tr> |
675 | | | <td><div id="NodeCoordinatesB">B klikni podruhe</div></td><td><div id="NodeDistanceBA">BA</div></td> |
676 | | | <td><div id="NodeAngleBAC">BAC</div></td><td><div id="NodeDistanceBC">BC</div></td> |
677 | | | </tr> |
678 | | | <tr> |
679 | | | <td><div id="NodeCoordinatesC">C klikni potreti</div></td><td><div id="NodeDistanceCA">CA</div></td> |
680 | | | <td><div id="NodeDistanceCB">CB</div></td><td><div id="NodeAngleCBA">BAC</div></td> |
681 | | | </tr> |
682 | | | <tr> |
683 | | | <td></td><td><div id="NodeDistanceBAC">B-A-C</div></td> |
684 | | | <td><div id="NodeDistanceABC">A-B-C</div></td><td><div id="NodeDistanceBCA">B-C-A</div></td> |
685 | | | </tr> |
686 | | | </table> |
687 | 1 | simandl | </td> |
688 | 9 | simandl | |
689 | | | </td> |
690 | 1 | simandl | </tr> |
691 | | | |
692 | | | <tr> |
693 | | | <td colspan=2> |
694 | | | <br> |
695 | | | CZFGmap (c) Petr Simandl - GNU General Public License |
696 | | | <br> |
697 | | | <a href="http://websvn.prosek.czf/">websvn.prosek.czf</a> |
698 | | | </td> |
699 | | | </tr> |
700 | | | |
701 | | | </table> |
702 | | | |
703 | | | </body> |
704 | | | </html> |
705 | 5 | simandl | '; |
706 | | | ?> |