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