[7722] | 1 | //Declaring some variables we will be using
|
---|
[7694] | 2 | var map;
|
---|
| 3 | var toggleState = 1;
|
---|
[7722] | 4 | var marker_hash = {};
|
---|
[7732] | 5 | var markerArray = new Array();
|
---|
[7734] | 6 | var xmlhttp;
|
---|
| 7 | var targetDiv = "infotop";
|
---|
[7756] | 8 | var selected;
|
---|
| 9 | var overNode;
|
---|
[7665] | 10 |
|
---|
[7778] | 11 |
|
---|
[7734] | 12 | //This function is called from index.php
|
---|
| 13 | function initialize_map() {
|
---|
| 14 | //We will only do this function if the browser is compatible
|
---|
| 15 | if (GBrowserIsCompatible()) {
|
---|
| 16 | //Adding the google map into the div called #mapcanvas
|
---|
| 17 | map = new GMap2(document.getElementById("mapcanvas"));
|
---|
| 18 | //Center the map on Leiden
|
---|
| 19 | map.setCenter(new GLatLng(52.162687, 4.493294), 11);
|
---|
| 20 | map.setUIToDefault();
|
---|
[7778] | 21 |
|
---|
[7734] | 22 |
|
---|
| 23 | //Go through the array 'markers' (Declared in index.php) and add a marker for each marker stored in the array using our addMarker function
|
---|
| 24 | for (var i=0; i<markers.length; i++) {
|
---|
| 25 | var current = markers[i];
|
---|
[7767] | 26 | var gMarker = addMarker(current, i);
|
---|
[7734] | 27 | }
|
---|
[7694] | 28 |
|
---|
[7756] | 29 | GEvent.addListener(map, "click", function() {
|
---|
[7778] | 30 |
|
---|
| 31 |
|
---|
| 32 |
|
---|
[7756] | 33 | if(!overNode == true)
|
---|
| 34 | deSelect();
|
---|
| 35 | });
|
---|
| 36 |
|
---|
[7767] | 37 | /*
|
---|
| 38 | * Hier zo circles toevoegen.
|
---|
| 39 | */
|
---|
| 40 |
|
---|
[7734] | 41 | var markerClusterer = new MarkerClusterer(map, markerArray);
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | //This function will contain the displaying and not displaying of nodes on the map
|
---|
| 46 | function toggleMyKml() {
|
---|
| 47 |
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | //This function adds a marker with an object from our 'marker'array defined in index.php
|
---|
| 51 | function addMarker(current, i) {
|
---|
| 52 | var id = current.id;
|
---|
[7783] | 53 | var marker = new GMarker(new GLatLng(current.latitude[0], current.longitude[0]), {title: current.name[0], icon: greenIcon});
|
---|
[7734] | 54 | //Added mouseover listener that calls on our mouseOver function when the mouse moves over a marker on the map
|
---|
| 55 | GEvent.addListener(marker, 'mouseover', function() {
|
---|
[7779] | 56 | //mouseOverNode(current.id, current.name[0],52.118860692234, 4.5015095076528);
|
---|
| 57 | mouseOverNode(current.id, current.name[0],current.latitude[0], current.longitude[0]);
|
---|
[7734] | 58 | });
|
---|
[7756] | 59 | GEvent.addListener(marker, 'click', function() {
|
---|
| 60 | mouseClickNode(current.id, current.name[0]);
|
---|
| 61 | });
|
---|
| 62 | GEvent.addListener(marker, 'mouseout', function() {
|
---|
| 63 | mouseOutNode(current.id, current.name[0]);
|
---|
| 64 | });
|
---|
| 65 |
|
---|
[7734] | 66 | markerArray[i] = marker;
|
---|
| 67 | return marker;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[7756] | 70 |
|
---|
[7734] | 71 | //Our mouseover function for single nodes. Gives the ID(our own given ID) and the name of the node.
|
---|
[7756] | 72 | function mouseClickNode(id, name)
|
---|
[7734] | 73 | {
|
---|
[7756] | 74 | selected = true;
|
---|
[7782] | 75 |
|
---|
[7778] | 76 | map.removeOverlay(polygon);
|
---|
[7734] | 77 | /*
|
---|
| 78 | *Hieronder verdergaan met dekking
|
---|
| 79 | */
|
---|
[7778] | 80 |
|
---|
[7756] | 81 |
|
---|
[7778] | 82 |
|
---|
| 83 |
|
---|
[7734] | 84 | }
|
---|
[7756] | 85 | //Our mouseover function for single nodes. Gives the ID(our own given ID) and the name of the node.
|
---|
[7782] | 86 | function mouseOverNode(id, name, lat, longitude)
|
---|
[7756] | 87 | {
|
---|
| 88 | if(!selected == true)
|
---|
| 89 | {
|
---|
| 90 | overNode = true;
|
---|
[7782] | 91 | loadXMLDoc("inc/node_info.php?type=single&name="+name+"");
|
---|
| 92 |
|
---|
[7779] | 93 | //alert(long);
|
---|
[7756] | 94 | /*
|
---|
| 95 | *Hieronder verdergaan met dekking
|
---|
| 96 | */
|
---|
[7782] | 97 | drawCircle(lat, longitude, 2.0, "#6C3", 1, 0.75, "#0F0",.2);
|
---|
[7756] | 98 | }
|
---|
| 99 | }
|
---|
[7734] | 100 |
|
---|
[7756] | 101 | function mouseOutNode(id, name)
|
---|
| 102 | {
|
---|
| 103 | overNode = false;
|
---|
[7778] | 104 | map.removeOverlay(polygon);
|
---|
| 105 |
|
---|
[7756] | 106 | }
|
---|
| 107 |
|
---|
[7734] | 108 | //Our mouseover function for Cluster nodes. 'markers' is an array containing all markers within the cluster
|
---|
| 109 | function mouseOverCluster(markers)
|
---|
| 110 | {
|
---|
[7756] | 111 | if(!selected == true)
|
---|
| 112 | {
|
---|
| 113 | //Make 'markers' array (containing gmarkers) into an array containing only the titles(names) of the markers
|
---|
| 114 | var markerTitles = new Array;
|
---|
| 115 | for(var i=0; i<markers.length; i++) {
|
---|
| 116 | markerTitles.push(markers[i].marker.getTitle());
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | var markerTitleSerialized;
|
---|
| 120 |
|
---|
| 121 | //start
|
---|
| 122 | var a_php = "";
|
---|
| 123 | var total = 0;
|
---|
| 124 |
|
---|
| 125 | for (var i=0; i<markerTitles.length; i++)
|
---|
| 126 | {
|
---|
| 127 | ++ total;
|
---|
| 128 | a_php = a_php + "s:" +
|
---|
| 129 | String(i).length + ":\"" + String(i) + "\";s:" +
|
---|
| 130 | String(markerTitles[i]).length + ":\"" + String(markerTitles[i]) + "\";";
|
---|
| 131 | }
|
---|
| 132 | a_php = "a:" + total + ":{" + a_php + "}";
|
---|
| 133 | //end
|
---|
| 134 |
|
---|
| 135 | loadXMLDoc("inc/node_info.php?type=cluster&markers="+a_php+"")
|
---|
| 136 | /*
|
---|
| 137 | *Hieronder verdergaan met dekking
|
---|
| 138 | */
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | //Our click function for Cluster nodes. 'markers' is an array containing all markers within the cluster
|
---|
| 143 | function clickCluster(markers)
|
---|
| 144 | {
|
---|
| 145 | //Let the rest of the program know that something is selected
|
---|
| 146 | select();
|
---|
| 147 |
|
---|
[7736] | 148 | //Make 'markers' array (containing gmarkers) into an array containing only the titles(names) of the markers
|
---|
[7734] | 149 | var markerTitles = new Array;
|
---|
| 150 | for(var i=0; i<markers.length; i++) {
|
---|
| 151 | markerTitles.push(markers[i].marker.getTitle());
|
---|
[7722] | 152 | }
|
---|
[7733] | 153 |
|
---|
[7735] | 154 | var markerTitleSerialized;
|
---|
| 155 |
|
---|
| 156 | //start
|
---|
| 157 | var a_php = "";
|
---|
| 158 | var total = 0;
|
---|
| 159 |
|
---|
| 160 | for (var i=0; i<markerTitles.length; i++)
|
---|
| 161 | {
|
---|
| 162 | ++ total;
|
---|
| 163 | a_php = a_php + "s:" +
|
---|
| 164 | String(i).length + ":\"" + String(i) + "\";s:" +
|
---|
| 165 | String(markerTitles[i]).length + ":\"" + String(markerTitles[i]) + "\";";
|
---|
| 166 | }
|
---|
| 167 | a_php = "a:" + total + ":{" + a_php + "}";
|
---|
| 168 | //end
|
---|
| 169 |
|
---|
[7756] | 170 | loadXMLDoc("inc/node_info.php?type=cluster&markers="+a_php+"&sel=selected")
|
---|
[7734] | 171 | }
|
---|
[7665] | 172 |
|
---|
[7756] | 173 | function select()
|
---|
[7738] | 174 | {
|
---|
[7756] | 175 | selected = true;
|
---|
[7738] | 176 | }
|
---|
[7734] | 177 |
|
---|
[7756] | 178 | function deSelect()
|
---|
| 179 | {
|
---|
| 180 | selected = false;
|
---|
| 181 | loadXMLDoc("inc/node_info.php");
|
---|
| 182 | }
|
---|
[7738] | 183 |
|
---|
[7734] | 184 | //Code from w3schools. http://www.w3schools.com/dom/dom_http.asp
|
---|
| 185 | function loadXMLDoc(url)
|
---|
| 186 | {
|
---|
| 187 | xmlhttp=null;
|
---|
| 188 | if (window.XMLHttpRequest)
|
---|
| 189 | {// code for Firefox, Opera, IE7, etc.
|
---|
| 190 | xmlhttp=new XMLHttpRequest();
|
---|
| 191 | }
|
---|
| 192 | else if (window.ActiveXObject)
|
---|
| 193 | {// code for IE6, IE5
|
---|
| 194 | xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
---|
| 195 | }
|
---|
| 196 | if (xmlhttp!=null)
|
---|
| 197 | {
|
---|
| 198 | xmlhttp.onreadystatechange=state_Change;
|
---|
| 199 | xmlhttp.open("GET",url,true);
|
---|
| 200 | xmlhttp.send(null);
|
---|
| 201 | }
|
---|
| 202 | else
|
---|
| 203 | {
|
---|
| 204 | alert("Your browser does not support XMLHTTP.");
|
---|
| 205 | }
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | function state_Change()
|
---|
| 209 | {
|
---|
| 210 | if (xmlhttp.readyState==4)
|
---|
| 211 | {// 4 = "loaded"
|
---|
| 212 | if (xmlhttp.status==200)
|
---|
| 213 | {// 200 = "OK"
|
---|
| 214 | document.getElementById(targetDiv).innerHTML=xmlhttp.responseText;
|
---|
| 215 | }
|
---|
| 216 | else
|
---|
| 217 | {
|
---|
| 218 | alert("Problem retrieving data:" + xmlhttp.statusText);
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
[7778] | 222 |
|
---|
| 223 |
|
---|
| 224 |
|
---|
| 225 |
|
---|
| 226 |
|
---|