Changeset 7847 for trunk/src/map/inc
- Timestamp:
- Apr 19, 2010, 11:26:15 AM (15 years ago)
- Location:
- trunk/src/map/inc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/map/inc/kmlHandler.php
r7842 r7847 5 5 //Check if the file exists, if it does we load it. If it doesn't we exit and return an error message 6 6 try { 7 $xml = simplexml_load_file( rawurlencode($file));7 $xml = simplexml_load_file($file); 8 8 } catch (Exception $e) { 9 9 trigger_error(SYSLOG_CRIT, 'Failed to open KML file: ' . $file, __FILE__, __LINE__); -
trunk/src/map/inc/node_info.php
r7828 r7847 119 119 elseif($_GET['type'] == "cluster") 120 120 { 121 $markerTitles = unserialize( $_GET['markers']);121 $markerTitles = unserialize(stripslashes($_GET['markers'])); 122 122 123 123 echo <<<EOF -
trunk/src/map/inc/nodemapWL.js
r7835 r7847 5 5 var markerArray = []; 6 6 var circleArray = []; 7 var totalCircleArray = []; 7 8 var polygons_on_map_array = []; 8 9 var xmlhttp; … … 13 14 var highlightCircle; 14 15 var currentMarker; 15 16 17 18 //This function is called from index.php 16 var toggleCircles = false; 17 18 // This function is called from index.php 19 19 function initialize_map() { 20 //We will only do this function if the browser is compatible 21 if (GBrowserIsCompatible()) 22 { 23 //Adding the google map into the div called #mapcanvas 24 map = new GMap2(document.getElementById("mapcanvas"), {googleBarOptions : {style : "new"}}); 25 //Center the map on Leiden 26 map.setCenter(new GLatLng(52.162687, 4.493294), 11); // Vars should go to config 27 map.setUIToDefault(); 28 29 30 /* 31 * Go through the array 'markers' (Declared in index.php) and add a marker for each marker stored in the array 32 * using our addMarker function. 33 * If the latLng of the marker is both 0 34 */ 35 for (var i=0; i<markers.length; i++) { 20 // We will only do this function if the browser is compatible 21 if (GBrowserIsCompatible()) { 22 // Adding the google map into the div called #mapcanvas 23 map = new GMap2(document.getElementById("mapcanvas"), { 24 googleBarOptions : { 25 style : "new" 26 } 27 }); 28 // Center the map on Leiden 29 map.setCenter(new GLatLng(52.162687, 4.493294), 11); // Vars should 30 // go to config 31 map.setUIToDefault(); 32 33 /* 34 * Go through the array 'markers' (Declared in index.php) and add a 35 * marker for each marker stored in the array using our addMarker 36 * function. If the latLng of the marker is both 0 37 */ 38 for ( var i = 0; i < markers.length; i++) { 36 39 var current = markers[i]; 37 if(current.latitude[0] > 0 || current.latitude[0] < 0) 38 { 40 if (current.latitude[0] > 0 || current.latitude[0] < 0) { 39 41 addMarker(current, i); 40 42 } 41 43 } 42 44 43 45 GEvent.addListener(map, "click", function() { 44 if (!overNode == true)46 if (!overNode == true) 45 47 deSelect(); 46 48 }); 47 49 48 50 GEvent.addListener(map, "zoomend", function() { 49 51 mapZoomed(); 50 52 }); 51 53 52 54 suggestMarkers(""); 53 55 54 56 new MarkerClusterer(map, markerArray); 55 57 } 56 } 57 58 //This function will contain the displaying and not displaying of nodes on the map 58 } 59 60 // This function will contain the displaying and not displaying of nodes on the 61 // map 59 62 function toggleMyKml() { 60 63 61 64 } 62 65 63 //This function adds a marker with an object from our 'marker'array defined in index.php 66 // This function adds a marker with an object from our 'marker'array defined in 67 // index.php 64 68 function addMarker(current, i) { 65 69 var latitude = Number(current.latitude[0]); 66 70 var longitude = Number(current.longitude[0]); 67 71 68 72 var displayIcon; 69 73 var currentstatus = current.status[0]; 70 if(currentstatus == "up") 71 { 74 if (currentstatus == "up") { 72 75 displayIcon = greenIcon; 73 } 74 else 75 { 76 } else { 76 77 displayIcon = redIcon; 77 78 } 78 79 var marker = new GMarker(new GLatLng(current.latitude[0], current.longitude[0]), {title: current.name[0], icon: displayIcon}); 80 81 //Added mouseover listener that calls on our mouseOver function when the mouse moves over a marker on the map 79 80 var marker = new GMarker(new GLatLng(current.latitude[0], 81 current.longitude[0]), { 82 title : current.name[0], 83 icon : displayIcon 84 }); 85 86 // Added mouseover listener that calls on our mouseOver function when the 87 // mouse moves over a marker on the map 82 88 GEvent.addListener(marker, 'mouseover', function() { 83 mouseOverNode(current.id, current.name[0],latitude, longitude);89 mouseOverNode(current.id, current.name[0], latitude, longitude); 84 90 }); 85 91 GEvent.addListener(marker, 'click', function() { 86 mouseClickNode(current.id, current.name[0], marker);92 mouseClickNode(current.id, current.name[0], marker); 87 93 }); 88 94 GEvent.addListener(marker, 'mouseout', function() { 89 mouseOutNode(current.id, current.name[0]);95 mouseOutNode(current.id, current.name[0]); 90 96 }); 91 97 92 98 markerArray.push(marker); 93 // circleArray.push(circle);99 // circleArray.push(circle); 94 100 return marker; 95 101 } 96 102 97 //Our mouseover function for single nodes. Gives the ID(our own given ID) and the name of the node. 98 function mouseClickNode(id, name, marker) 99 { 100 if(selected == true) 101 { 103 // Our mouseover function for single nodes. Gives the ID(our own given ID) and 104 // the name of the node. 105 function mouseClickNode(id, name, marker) { 106 if (selected == true) { 102 107 deSelect(); 103 108 markerSelected = ""; 104 109 } 105 106 if(markerSelected == marker) 107 { 110 111 if (markerSelected == marker) { 108 112 deSelect(); 109 113 markerSelected = ""; 110 } 111 else 112 { 114 } else { 113 115 selected = true; 114 116 markerSelected = marker; 115 for(var i=0; i<markers.length; i++) 116 { 117 var currentmarker = markers[i]; 118 if(currentmarker.name[0] == marker.getTitle()) 119 { 120 if(currentmarker.status[0] == "up") 121 { 117 for ( var i = 0; i < markers.length; i++) { 118 var currentmarker = markers[i]; 119 if (currentmarker.name[0] == marker.getTitle()) { 120 if (currentmarker.status[0] == "up") { 122 121 marker.setImage("../img/sleutelGroenSelected.png"); 123 } 124 else 125 { 122 } else { 126 123 marker.setImage("../img/sleutelRoodSelected.png"); 127 124 } 128 125 129 126 } 130 127 } 131 loadXMLDoc("inc/node_info.php?type=single&name="+name+"&a="+Math.random()); 132 } 133 } 134 //Our mouseover function for single nodes. Gives the ID(our own given ID) and the name of the node. 135 function mouseOverNode(id, name, latitude, longitude) 136 { 128 loadXMLDoc("inc/node_info.php?type=single&name=" + name + "&a=" 129 + Math.random()); 130 } 131 } 132 // Our mouseover function for single nodes. Gives the ID(our own given ID) and 133 // the name of the node. 134 function mouseOverNode(id, name, latitude, longitude) { 137 135 overNode = true; 138 if(!selected == true) 139 { 140 141 drawCircle(latitude, longitude,0.1, "#6C3", 1, 0.75, "#0F0",.2, 200); 136 if (!selected == true) { 137 138 drawCircle(latitude, longitude, 0.1, "#6C3", 1, 0.75, "#0F0", .2, 200); 142 139 polygons_on_map_array.push(polygon); 143 140 map.addOverlay(polygon); 144 145 loadXMLDoc("inc/node_info.php?type=single&name="+name+"&a="+Math.random());//Path should be in config 141 142 loadXMLDoc("inc/node_info.php?type=single&name=" + name + "&a=" 143 + Math.random());// Path should be in config 146 144 147 145 /* 148 *Hieronder verdergaan met dekking 149 */ 150 151 } 152 } 153 154 function mouseOutNode(id, name) 155 { 146 * Hieronder verdergaan met dekking 147 */ 148 149 } 150 } 151 152 function mouseOutNode(id, name) { 156 153 overNode = false; 157 154 map.removeOverlay(polygon); … … 159 156 } 160 157 161 // Our mouseover function for Cluster nodes. 'markers' is an array containing all markers within the cluster162 function mouseOverCluster(markers) 163 {164 if (!selected == true)165 {166 // Make 'markers' array (containing gmarkers) into an array containingonly the titles(names) of the markers158 // Our mouseover function for Cluster nodes. 'markers' is an array containing 159 // all markers within the cluster 160 function mouseOverCluster(markers) { 161 if (!selected == true) { 162 // Make 'markers' array (containing gmarkers) into an array containing 163 // only the titles(names) of the markers 167 164 var markerTitles = new Array; 168 165 var markerLatLngs = new Array; 169 170 for(var i=0; i<markers.length; i++) { 171 166 167 for ( var i = 0; i < markers.length; i++) { 172 168 markerTitles.push(markers[i].marker.getTitle()); 173 markerLatLngs.push(markers[i].marker.getLatLng() ); 174 } 175 176 177 178 for (var i=0; i<markerLatLngs.length; i++) 179 { 180 latLng = String(markerLatLngs[i]); 181 169 markerLatLngs.push(markers[i].marker.getLatLng()); 170 } 171 172 var markerTitleSerialized; 173 174 // start 175 var a_php = ""; 176 var total = 0; 177 178 for ( var i = 0; i < markerTitles.length; i++) { 179 ++total; 180 a_php = a_php + "s:" + String(i).length + ":\"" + String(i) 181 + "\";s:" + String(markerTitles[i]).length + ":\"" 182 + String(markerTitles[i]) + "\";"; 183 } 184 a_php = "a:" + total + ":{" + a_php + "}"; 185 // end 186 187 loadXMLDoc("inc/node_info.php?type=cluster&markers=" + a_php + "&rand=" 188 + Math.random()); 189 /* 190 * Hieronder verdergaan met dekking 191 */ 192 193 for ( var i = 0; i < markerLatLngs.length; i++) { 194 latLng = String(markerLatLngs[i]); 195 182 196 pos = latLng.indexOf(','); 183 pos2 = latLng.length-1; 184 185 var latitude = Number(latLng.substring(1, pos) ); 186 var longitude = Number(latLng.substring(2 + pos, pos2) ); 187 188 189 drawCircle( latitude, longitude,0.1, "#6C3", 1, 0.75, "#0F0",.2); 190 191 197 pos2 = latLng.length - 1; 198 199 var latitude = Number(latLng.substring(1, pos)); 200 var longitude = Number(latLng.substring(2 + pos, pos2)); 201 202 drawCircle(latitude, longitude, 0.1, "#6C3", 1, 0.75, "#0F0", .2); 192 203 193 204 map.addOverlay(polygon); 194 205 polygons_on_map_array.push(polygon); 195 206 } 196 197 var markerTitleSerialized; 198 199 //start 200 var a_php = ""; 201 var total = 0; 202 203 for (var i=0; i<markerTitles.length; i++) 204 { 205 ++ total; 206 a_php = a_php + "s:" + 207 String(i).length + ":\"" + String(i) + "\";s:" + 208 String(markerTitles[i]).length + ":\"" + String(markerTitles[i]) + "\";"; 209 } 210 a_php = "a:" + total + ":{" + a_php + "}"; 211 //end 212 213 loadXMLDoc("inc/node_info.php?type=cluster&markers="+a_php+"") 214 /* 215 *Hieronder verdergaan met dekking 216 */ 217 } 218 } 219 220 //Our click function for Cluster nodes. 'markers' is an array containing all markers within the cluster 221 function clickCluster(markers) 222 { 223 if(selected == true) 207 } 208 } 209 210 // Our click function for Cluster nodes. 'markers' is an array containing all 211 // markers within the cluster 212 function clickCluster(markers) { 213 if (selected == true) 224 214 deselect(); 225 226 // Let the rest of the program know that something is selected215 216 // Let the rest of the program know that something is selected 227 217 select(); 228 218 229 //Make 'markers' array (containing gmarkers) into an array containing only the titles(names) of the markers 219 // Make 'markers' array (containing gmarkers) into an array containing only 220 // the titles(names) of the markers 230 221 var markerTitles = new Array; 231 for (var i=0; i<markers.length; i++) {222 for ( var i = 0; i < markers.length; i++) { 232 223 markerTitles.push(markers[i].marker.getTitle()); 233 234 } 235 224 225 } 226 236 227 var markerTitleSerialized; 237 238 // start228 229 // start 239 230 var a_php = ""; 240 var total = 0; 241 242 for (var i=0; i<markerTitles.length; i++) 243 { 244 ++ total; 245 a_php = a_php + "s:" + 246 String(i).length + ":\"" + String(i) + "\";s:" + 247 String(markerTitles[i]).length + ":\"" + String(markerTitles[i]) + "\";"; 248 } 249 a_php = "a:" + total + ":{" + a_php + "}"; 250 //end 251 252 loadXMLDoc("inc/node_info.php?type=cluster&markers="+a_php+"&sel=selected"+"&a="+Math.random()) 253 } 254 255 function mouseOutCluster(markers) 256 { 231 var total = 0; 232 233 for ( var i = 0; i < markerTitles.length; i++) { 234 ++total; 235 a_php = a_php + "s:" + String(i).length + ":\"" + String(i) + "\";s:" 236 + String(markerTitles[i]).length + ":\"" 237 + String(markerTitles[i]) + "\";"; 238 } 239 a_php = "a:" + total + ":{" + a_php + "}"; 240 // end 241 242 loadXMLDoc("inc/node_info.php?type=cluster&markers=" + a_php 243 + "&sel=selected" + "&a=" + Math.random()) 244 } 245 246 function mouseOutCluster(markers) { 257 247 removeAllPolgygons(); 258 248 } 259 249 260 function mapZoomed() 261 { 262 263 if(!markerSelected == "") 264 { 250 function mapZoomed() { 251 252 if (!markerSelected == "") { 265 253 markerSelected.setImage("../img/sleutelGroenSelected.png"); 266 254 } 267 255 268 256 if (highlightCircle) { 269 257 map.removeOverlay(highlightCircle); 270 } 271 } 272 273 function removeAllPolgygons() 274 { 275 for(var i=0; i<polygons_on_map_array.length; i++) 276 { 258 } 259 } 260 261 function removeAllPolgygons() { 262 for ( var i = 0; i < polygons_on_map_array.length; i++) { 277 263 var currentpolygon = polygons_on_map_array[i]; 278 264 map.removeOverlay(currentpolygon); 279 265 280 266 } 281 267 polygons_on_map_array.clear(); 282 268 } 283 269 284 function select() 285 { 270 function select() { 286 271 selected = true; 287 272 } 288 273 289 function deSelect() 290 { 274 function deSelect() { 291 275 map.removeOverlay(highlightCircle); 292 276 selected = false; 293 277 loadXMLDoc("inc/node_info.php"); 294 if(!markerSelected == "") 295 { 296 for(var i=0; i<markers.length; i++) 297 { 298 var currentmarker = markers[i]; 299 if(currentmarker.name[0] == markerSelected.getTitle()) 300 { 301 if(currentmarker.status[0] == "up") 302 { 278 if (!markerSelected == "") { 279 for ( var i = 0; i < markers.length; i++) { 280 var currentmarker = markers[i]; 281 if (currentmarker.name[0] == markerSelected.getTitle()) { 282 if (currentmarker.status[0] == "up") { 303 283 markerSelected.setImage("../img/sleutelGroen.png"); 304 } 305 else 306 { 284 } else { 307 285 markerSelected.setImage("../img/sleutelRood.png"); 308 286 } 309 287 310 288 } 311 289 } 312 290 markerSelected = ""; 313 291 } 314 292 315 293 removeAllPolgygons(); 316 317 } 318 319 function removeOtherSelect() 320 { 321 for(var i=0; i<markerArray.length; i++) 322 { 294 295 } 296 297 function removeOtherSelect() { 298 for ( var i = 0; i < markerArray.length; i++) { 323 299 currentmarker = markerArray[i]; 324 300 currentmarker.setImage("../sleutelGroen.png"); … … 327 303 } 328 304 329 //Code from w3schools. http://www.w3schools.com/dom/dom_http.asp 330 function loadXMLDoc(url, targetDiv) 331 { 332 xmlhttp=null; 333 if (window.XMLHttpRequest) 334 {// code for Firefox, Opera, IE7, etc. 335 xmlhttp=new XMLHttpRequest(); 336 } 337 else if (window.ActiveXObject) 338 {// code for IE6, IE5 339 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 340 } 341 if (xmlhttp!=null) 342 { 343 xmlhttp.onreadystatechange=state_Change(); 344 xmlhttp.open("GET",url,true); 345 xmlhttp.send(null); 346 } 347 else 348 { 349 alert("Your browser does not support XMLHTTP."); 350 } 351 } 352 353 function state_Change() 354 { 355 if (xmlhttp.readyState==4) 356 {// 4 = "loaded" 357 if (xmlhttp.status==200) 358 {// 200 = "OK" 359 document.getElementById(targetDiv).innerHTML=xmlhttp.responseText; 360 } 361 else 362 { 363 alert("Problem retrieving data:" + xmlhttp.statusText); 364 } 365 } 366 } 367 368 function loadSuggest(url) 369 { 370 xmlhttp=null; 371 if (window.XMLHttpRequest) 372 {// code for Firefox, Opera, IE7, etc. 373 xmlhttp=new XMLHttpRequest(); 374 } 375 else if (window.ActiveXObject) 376 {// code for IE6, IE5 377 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 378 } 379 if (xmlhttp!=null) 380 { 381 xmlhttp.onreadystatechange=state_ChangeSuggest; 382 xmlhttp.open("GET",url,true); 383 xmlhttp.send(null); 384 } 385 else 386 { 387 alert("Your browser does not support XMLHTTP."); 388 } 389 } 390 391 function state_ChangeSuggest() 392 { 393 if (xmlhttp.readyState==4) 394 {// 4 = "loaded" 395 if (xmlhttp.status==200) 396 {// 200 = "OK" 397 document.getElementById("searchlist").innerHTML=xmlhttp.responseText; 398 } 399 else 400 { 401 alert("Problem retrieving data:" + xmlhttp.statusText); 402 } 403 } 404 } 405 406 function suggestMarkers(value) 407 { 408 loadSuggest("inc/suggestions.php?value="+value+"&a="+Math.random()); 409 } 410 411 function goToMarker(value) 412 { 413 for(var i=0; i<markerArray.length; i++) 414 { 305 // Code from w3schools. http://www.w3schools.com/dom/dom_http.asp 306 function loadXMLDoc(url, targetDiv) { 307 xmlhttp = null; 308 if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc. 309 xmlhttp = new XMLHttpRequest(); 310 } else if (window.ActiveXObject) {// code for IE6, IE5 311 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 312 } 313 if (xmlhttp != null) { 314 xmlhttp.onreadystatechange = state_Change(); 315 xmlhttp.open("GET", url, true); 316 xmlhttp.send(null); 317 } else { 318 alert("Your browser does not support XMLHTTP."); 319 } 320 } 321 322 function state_Change() { 323 if (xmlhttp.readyState == 4) {// 4 = "loaded" 324 if (xmlhttp.status == 200) {// 200 = "OK" 325 document.getElementById(targetDiv).innerHTML = xmlhttp.responseText; 326 } else { 327 alert("Problem retrieving data:" + xmlhttp.statusText); 328 } 329 } 330 } 331 332 function loadSuggest(url) { 333 xmlhttp = null; 334 if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc. 335 xmlhttp = new XMLHttpRequest(); 336 } else if (window.ActiveXObject) {// code for IE6, IE5 337 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 338 } 339 if (xmlhttp != null) { 340 xmlhttp.onreadystatechange = state_ChangeSuggest; 341 xmlhttp.open("GET", url, true); 342 xmlhttp.send(null); 343 } else { 344 alert("Your browser does not support XMLHTTP."); 345 } 346 } 347 348 function state_ChangeSuggest() { 349 if (xmlhttp.readyState == 4) {// 4 = "loaded" 350 if (xmlhttp.status == 200) {// 200 = "OK" 351 document.getElementById("searchlist").innerHTML = xmlhttp.responseText; 352 } else { 353 alert("Problem retrieving data:" + xmlhttp.statusText); 354 } 355 } 356 } 357 358 function suggestMarkers(value) { 359 loadSuggest("inc/suggestions.php?value=" + value + "&a=" + Math.random()); 360 } 361 362 function goToMarker(value) { 363 for ( var i = 0; i < markerArray.length; i++) { 415 364 var name = markerArray[i].getTitle(); 416 417 if(name == value) 418 { 365 366 if (name == value) { 419 367 map.setCenter(markerArray[i].getLatLng(), 15); 420 loadXMLDoc("inc/node_info.php?type=single&name="+value+"&a="+Math.random()) 421 } 422 } 423 } 424 425 function toggleGoogleSearchMap() 426 { 427 if(gmap_search_state) 428 { 368 loadXMLDoc("inc/node_info.php?type=single&name=" + value + "&a=" 369 + Math.random()) 370 } 371 } 372 } 373 374 function toggleGoogleSearchMap() { 375 if (gmap_search_state) { 429 376 gmap_search_state = false; 430 } 431 else 432 { 377 } else { 433 378 gmap_search_state = true; 434 379 } 435 436 if(gmap_search_state) 437 { 380 381 if (gmap_search_state) { 438 382 map.enableGoogleBar(); 439 383 } 440 441 if(!gmap_search_state) 442 { 384 385 if (!gmap_search_state) { 443 386 map.disableGoogleBar(); 444 387 } 445 388 } 446 389 447 448 390 function toggleAllCircles() { 391 toggleCircles = !toggleCircles; 392 393 if (toggleCircles == true) { 394 for ( var i = 0; i < markers.length; i++) { 395 var current = markers[i]; 396 if (current.latitude[0] > 0 || current.latitude[0] < 0) { 397 drawCircle(Number(current.latitude[0]), Number(current.longitude[0]), 0.1, "#6C3", 1, 0.75, "#0F0", .2); 398 399 map.addOverlay(polygon); 400 totalCircleArray.push(polygon); 401 } 402 } 403 } else { 404 for ( var i = 0; i < totalCircleArray.length; i++) { 405 var currentpolygon = totalCircleArray[i]; 406 map.removeOverlay(currentpolygon); 407 408 } 409 totalCircleArray.clear(); 410 } 411 }
Note:
See TracChangeset
for help on using the changeset viewer.