Changeset 91
- Timestamp:
- 09/20/2005 08:07:33 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
-
includes/pages/gmap/gmap_js.php (modified) (1 diff)
-
includes/pages/gmap/gmap_xml.php (modified) (4 diffs)
-
templates/basic/images/gmap/mm_20_grey.png (added)
-
templates/basic/images/gmap/mm_50_grey.png (added)
-
templates/basic/includes/pages/gmap/gmap_js.tpl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/pages/gmap/gmap_js.php
r76 r91 71 71 72 72 } 73 $this->tpl['link_xml_page'] = makelink(array("page" => "gmap", "subpage" => "xml" ), FALSE, TRUE, FALSE);73 $this->tpl['link_xml_page'] = makelink(array("page" => "gmap", "subpage" => "xml", "node" => get('node')), FALSE, TRUE, FALSE); 74 74 75 75 echo template($this->tpl, __FILE__); -
trunk/includes/pages/gmap/gmap_xml.php
r64 r91 32 32 $node = $node[0]; 33 33 34 if (get('node') != '') $having .= ($having!=''?' OR ':'')."id = '".get('node')."'"; 34 35 if (get('show_p2p') == 1) $having .= ($having!=''?' OR ':'').'total_p2p > 0'; 35 36 if (get('show_aps') == 1) $having .= ($having!=''?' OR ':'').'total_aps > 0'; 36 if (get('show_clients') == 1) $having .= ($having!=''?' OR ':'').' total_client_on_ap > 0';37 if (get('show_unlinked') == 1) $having .= ($having!=''?' OR ':'').'(total_p2p = 0 AND total_ client_on_ap = 0)';38 $nodes = $db->get(37 if (get('show_clients') == 1) $having .= ($having!=''?' OR ':'').'(total_p2p = 0 AND total_aps = 0 AND total_client_on_ap > 0)'; 38 if (get('show_unlinked') == 1) $having .= ($having!=''?' OR ':'').'(total_p2p = 0 AND total_aps = 0 AND total_client_on_ap = 0)'; 39 if ($having != '') $nodes = $db->get( 39 40 'nodes.id, nodes.latitude, nodes.longitude, nodes.name AS nodes__name, areas.name AS areas__name, COUNT(DISTINCT p2p.id) AS total_p2p, COUNT(DISTINCT aps.id) AS total_aps, COUNT(DISTINCT clients.id) AS total_clients, COUNT(DISTINCT client_ap.id) AS total_client_on_ap', 40 41 'nodes … … 54 55 $xml .= "<nodes>\r"; 55 56 foreach ((array) $nodes as $key => $value) { 56 $xml .= "<node"; 57 $xml .= "<"; 58 if (get('node') == $value['id']) { 59 $xml .= 'selected'; 60 } elseif ($value['total_aps'] != 0 && $value['total_p2p'] != 0) { 61 $xml .= 'p2p-ap'; 62 } elseif ($value['total_aps'] != 0) { 63 $xml .= 'ap'; 64 } elseif ($value['total_p2p'] != 0) { 65 $xml .= 'p2p'; 66 } elseif ($value['total_client_on_ap'] != 0) { 67 $xml .= 'client'; 68 } else { 69 $xml .= 'unlinked'; 70 } 57 71 $xml .= ' id="'.$value['id'].'"'; 58 72 $xml .= ' name="'.htmlspecialchars($value['nodes__name']).'"'; … … 69 83 $xml .= "</nodes>\r"; 70 84 71 if (get('show_ p2p') == 1) $where .= ($where!=''?' OR ':'')."l2.type = 'p2p'";72 if (get('show_ clients') == 1) $where .= ($where!=''?' OR ':'')."l2.type = 'client'";73 $links = $db->get(74 'l2. type AS type, n1.latitude AS n1_lat, n1.longitude AS n1_lon, n2.latitude AS n2_lat, n2.longitude AS n2_lon, l1.status AS l1_status, l2.status AS l2_status',85 if (get('show_links_p2p') == 1) $where .= ($where!=''?' OR ':'')."l2.type = 'p2p'"; 86 if (get('show_links_client') == 1) $where .= ($where!=''?' OR ':'')."l2.type = 'client'"; 87 if ($where != '') $links = $db->get( 88 'l2.id AS id, l2.type AS type, n1.latitude AS n1_lat, n1.longitude AS n1_lon, n2.latitude AS n2_lat, n2.longitude AS n2_lon, l1.status AS l1_status, l2.status AS l2_status', 75 89 'links AS l1 ' . 76 90 "INNER JOIN links AS l2 ON (l1.id < l2.id AND l1.type = 'p2p' AND l2.type = 'p2p' AND l1.node_id = l2.peer_node_id AND l2.node_id = l1.peer_node_id) OR (l1.type = 'ap' AND l2.type = 'client' AND l1.id = l2.peer_ap_id) " . … … 81 95 $xml .= "<links>\r"; 82 96 foreach ((array) $links as $key => $value) { 83 $xml .= "<link ";84 $xml .= ' type="'.$value['type'].'"';97 $xml .= "<link_".$value['type']; 98 $xml .= ' id="'.$value['id'].'"'; 85 99 $xml .= ' lat1="'.$value['n1_lat'].'"'; 86 100 $xml .= ' lon1="'.$value['n1_lon'].'"'; -
trunk/templates/basic/includes/pages/gmap/gmap_js.tpl
r64 r91 21 21 {literal} 22 22 var map; 23 var nodes = Array(); 24 var links = Array(); 23 var selected = Array(); 24 var p2p_ap = Array(); 25 var p2p = Array(); 26 var aps = Array(); 27 var clients = Array(); 28 var unlinked = Array(); 29 var links_p2p = Array(); 30 var links_client = Array(); 25 31 var markers = Array(); 26 32 var polylines = Array(); 33 var ch_p2p; 34 var ch_aps; 35 var ch_clients; 36 var ch_unlinked; 27 37 28 38 // Markers Optimization … … 102 112 icon_red[1].infoWindowAnchor = new GPoint(10, 1); 103 113 114 var icon_grey = Array(new GIcon(), new GIcon()); 115 icon_grey[0].image = "{$img_dir}gmap/mm_20_grey.png"; 116 icon_grey[0].shadow = "{$img_dir}gmap/mm_20_shadow.png"; 117 icon_grey[0].iconSize = new GSize(12, 20); 118 icon_grey[0].shadowSize = new GSize(22, 20); 119 icon_grey[0].iconAnchor = new GPoint(6, 20); 120 icon_grey[0].infoWindowAnchor = new GPoint(5, 1); 121 122 icon_grey[1].image = "{$img_dir}gmap/mm_50_grey.png"; 123 icon_grey[1].shadow = "{$img_dir}gmap/mm_50_shadow.png"; 124 icon_grey[1].iconSize = new GSize(20, 34); 125 icon_grey[1].shadowSize = new GSize(37, 34); 126 icon_grey[1].iconAnchor = new GPoint(9, 32); 127 icon_grey[1].infoWindowAnchor = new GPoint(10, 1); 128 104 129 {literal} 105 130 function gmap_onload() { 131 ch_p2p = document.getElementsByName("p2p")[0]; 132 ch_aps = document.getElementsByName("aps")[0]; 133 ch_clients = document.getElementsByName("clients")[0]; 134 ch_unlinked = document.getElementsByName("unlinked")[0]; 106 135 if (GBrowserIsCompatible()) { 107 136 map = new GMap(document.getElementById("map")); … … 135 164 136 165 function gmap_reload() { 137 var markers_t = Array(); 138 var polylines_t = Array(); 139 var bounds = map.getBoundsLatLng(); 166 167 if (ch_aps.checked == true && ch_clients.checked == true) makePolylines(links_client, "#00ffff", "#ff0000", 2); 168 if (ch_p2p.checked == true) makePolylines(links_p2p, "#00ff00", "#ff0000", 3); 169 170 if (ch_unlinked.checked == true) makeMarkers(unlinked, icon_red, -1); 171 if (ch_clients.checked == true) makeMarkers(clients, icon_blue, -1); 172 if (ch_aps.checked == true) makeMarkers(aps, icon_green, 3); 173 if (ch_p2p.checked == true) makeMarkers(p2p, icon_orange, 3); 174 if (ch_p2p.checked == true || ch_aps.checked == true) makeMarkers(p2p_ap, icon_green, 3); 175 makeMarkers(selected, icon_grey, 3); 176 177 } 178 179 function gmap_refresh() { 140 180 var ch_p2p = document.getElementsByName("p2p")[0]; 141 181 var ch_aps = document.getElementsByName("aps")[0]; 142 182 var ch_clients = document.getElementsByName("clients")[0]; 143 183 var ch_unlinked = document.getElementsByName("unlinked")[0]; 184 if (((ch_p2p.checked == true && p2p.length > 0) || ch_p2p.checked == false) && 185 ((ch_aps.checked == true && aps.length > 0) || ch_aps.checked == false) && 186 ((ch_clients.checked == true && clients.length > 0) || ch_clients.checked == false) && 187 ((ch_unlinked.checked == true && unlinked.length > 0) || ch_unlinked.checked == false)) { 188 map.clearOverlays(); 189 markers = Array(); 190 polylines = Array(); 191 gmap_reload(); 192 return; 193 } 194 var request = GXmlHttp.create(); 195 var xml_url = "{/literal}{$link_xml_page}{literal}" + 196 (ch_p2p.checked == true && p2p.length == 0?"&show_p2p=1":"") + 197 (ch_aps.checked == true && aps.length == 0?"&show_aps=1":"") + 198 (ch_clients.checked == true && clients.length == 0?"&show_clients=1":"") + 199 (ch_unlinked.checked == true && unlinked.length == 0?"&show_unlinked=1":"") + 200 (ch_p2p.checked == true && links_p2p.length == 0?"&show_links_p2p=1":"") + 201 (ch_aps.checked == true && ch_clients.checked == true && links_client.length == 0?"&show_links_client=1":""); 202 request.open("GET", xml_url, true); 203 request.onreadystatechange = 204 function() { 205 if (request.readyState == 4) { 206 var xmlDoc = request.responseXML; 207 selected = xmlDoc.documentElement.getElementsByTagName("selected"); 208 if ((ch_p2p.checked == true || ch_aps.checked == true) && p2p_ap.length == 0) p2p_ap = xmlDoc.documentElement.getElementsByTagName("p2p-ap"); 209 if (ch_aps.checked == true && aps.length == 0) aps = xmlDoc.documentElement.getElementsByTagName("ap"); 210 if (ch_p2p.checked == true && p2p.length == 0) p2p = xmlDoc.documentElement.getElementsByTagName("p2p"); 211 if (ch_clients.checked == true && clients.length == 0) clients = xmlDoc.documentElement.getElementsByTagName("client"); 212 if (ch_unlinked.checked == true && unlinked.length == 0) unlinked = xmlDoc.documentElement.getElementsByTagName("unlinked"); 213 if (ch_p2p.checked == true && links_p2p.length == 0) links_p2p = xmlDoc.documentElement.getElementsByTagName("link_p2p"); 214 if (ch_aps.checked == true && ch_clients.checked == true && links_client.length == 0) links_client = xmlDoc.documentElement.getElementsByTagName("link_client"); 215 map.clearOverlays(); 216 markers = Array(); 217 polylines = Array(); 218 gmap_reload(); 219 } 220 } 221 request.send(null); 222 } 223 224 function createMarker(point, html, icon) { 225 var marker = new GMarker(point, icon); 226 GEvent.addListener(marker, "click", 227 function() { 228 marker.openInfoWindowHtml(html); 229 }); 230 231 return marker; 232 } 233 234 function makeMarkers(nodes, icon_image, icon_zoom) { 235 var markers_t = Array(); 236 var bounds = map.getBoundsLatLng(); 144 237 for (var i = 0; i < nodes.length; i++) { 145 if (markers[i] != undefined) continue;146 147 238 var node_id = nodes[i].getAttribute("id"); 148 var node_name = nodes[i].getAttribute("name");149 var node_area = nodes[i].getAttribute("area");150 var node_p2p = nodes[i].getAttribute("p2p") * 1;151 var node_aps = nodes[i].getAttribute("aps") * 1;152 var node_client_on_ap = nodes[i].getAttribute("client_on_ap") * 1;153 var node_clients = nodes[i].getAttribute("clients") * 1;154 239 var node_lat = nodes[i].getAttribute("lat"); 155 240 var node_lon = nodes[i].getAttribute("lon"); 156 var node_url = nodes[i].getAttribute("url"); 157 158 var show_p2p = node_p2p > 0 && 159 ch_p2p.checked == true; 160 var show_aps = node_aps > 0 && 161 ch_aps.checked == true; 162 var show_clients = node_client_on_ap > 0 && 163 ch_clients.checked == true; 164 var show_unl = node_p2p == 0 && 165 node_client_on_ap == 0 && 166 ch_unlinked.checked == true; 167 var show_nodes = show_p2p || show_aps || show_clients || show_unl; 241 242 if (markers[node_id] != undefined) continue; 243 168 244 var inbounds = node_lat >= bounds.minY && 169 245 node_lat <= bounds.maxY && 170 246 node_lon >= bounds.minX && 171 247 node_lon <= bounds.maxX; 172 if (show_nodes && inbounds) { 248 if (inbounds) { 249 var node_name = nodes[i].getAttribute("name"); 250 var node_area = nodes[i].getAttribute("area"); 251 var node_p2p = nodes[i].getAttribute("p2p") * 1; 252 var node_aps = nodes[i].getAttribute("aps") * 1; 253 var node_client_on_ap = nodes[i].getAttribute("client_on_ap") * 1; 254 var node_clients = nodes[i].getAttribute("clients") * 1; 255 var node_url = nodes[i].getAttribute("url"); 256 173 257 var point = new GPoint(node_lon, 174 258 node_lat); 175 259 var icon; var icon_s; 176 if (map.getZoomLevel() <= 3) {260 if (map.getZoomLevel() <= icon_zoom) { 177 261 var icon_scale = 1; 178 262 } else { 179 263 var icon_scale = 0; 180 264 } 181 if (node_aps > 0) { 182 icon = icon_green[icon_scale]; 183 icon_s = icon_green[0]; 184 } else if (node_p2p > 0) { 185 icon = icon_orange[icon_scale]; 186 icon_s = icon_orange[0]; 187 } else if (node_client_on_ap > 0) { 188 icon = icon_blue[0]; 189 icon_s = icon_blue[0]; 190 } else { 191 icon = icon_red[0]; 192 icon_s = icon_red[0]; 193 } 265 icon = icon_image[icon_scale]; 266 icon_s = icon_image[0]; 194 267 var html = "<div style=\"text-align:left; font-size:12px;font-weight:bold;\"><img src=\"" + icon_s.image + "\" alt=\"\" />" + node_name + " (#" + node_id + ")</div><br />" + 195 268 "<div style=\"text-align:left; font-size:10px;\">" + … … 200 273 var marker = createMarker(point, html, icon); 201 274 markers_t.push(marker); 202 markers[ i] = true;275 markers[node_id] = true; 203 276 } 204 277 } 278 map.addOverlays(markers_t); 279 } 280 281 function makePolylines(links, color_active, color_inactive, size) { 282 var polylines_t = Array(); 283 var bounds = map.getBoundsLatLng(); 205 284 for (var i = 0; i < links.length; i++) { 206 if (polylines[i] != undefined) continue; 207 var show_l_p2p = links[i].getAttribute("type") == "p2p" && 208 ch_p2p.checked == true; 209 var show_l_clients = links[i].getAttribute("type") == "client" && 210 ch_clients.checked == true; 211 var show_links = show_l_p2p || show_l_clients; 212 var l_inbound_1 = links[i].getAttribute("lat1") >= bounds.minY && 213 links[i].getAttribute("lat1") <= bounds.maxY && 214 links[i].getAttribute("lon1") >= bounds.minX && 215 links[i].getAttribute("lon1") <= bounds.maxX; 216 var l_inbound_2 = links[i].getAttribute("lat2") >= bounds.minY && 217 links[i].getAttribute("lat2") <= bounds.maxY && 218 links[i].getAttribute("lon2") >= bounds.minX && 219 links[i].getAttribute("lon2") <= bounds.maxX; 220 var l_inbounds = l_inbound_1 || l_inbound_2 221 if (show_links && l_inbounds) { 285 var link_id = links[i].getAttribute("id"); 286 if (polylines[link_id] != undefined) continue; 287 var link_lat1 = links[i].getAttribute("lat1"); 288 var link_lon1 = links[i].getAttribute("lon1"); 289 var link_lat2 = links[i].getAttribute("lat2"); 290 var link_lon2 = links[i].getAttribute("lon2"); 291 var l_inbound_1 = link_lat1 >= bounds.minY && 292 link_lat1 <= bounds.maxY && 293 link_lon1 >= bounds.minX && 294 link_lon1 <= bounds.maxX; 295 var l_inbound_2 = link_lat2 >= bounds.minY && 296 link_lat2 <= bounds.maxY && 297 link_lon2 >= bounds.minX && 298 link_lon2 <= bounds.maxX; 299 if (l_inbound_1 || l_inbound_2) { 222 300 if (links[i].getAttribute("status") == 'active') { 223 var color = "#00ff00";301 var color = color_active; 224 302 } else { 225 var color = "#ff0000";303 var color = color_inactive; 226 304 } 227 var point1 = new GPoint(links[i].getAttribute("lon1"), 228 links[i].getAttribute("lat1")); 229 var point2 = new GPoint(links[i].getAttribute("lon2"), 230 links[i].getAttribute("lat2")); 231 var polyline = new GPolyline([point1, point2], color, 232 (links[i].getAttribute("type")=="p2p"?3:1)); 305 var point1 = new GPoint(link_lon1, 306 link_lat1); 307 var point2 = new GPoint(link_lon2, 308 link_lat2); 309 var polyline = new GPolyline([point1, point2], color, size); 233 310 polylines_t.push(polyline); 234 polylines[ i] = true;311 polylines[link_id] = true; 235 312 } 236 313 } 237 map.addOverlays(markers_t); 238 map.addOverlays(polylines_t); 239 } 240 241 function gmap_refresh() { 242 var ch_p2p = document.getElementsByName("p2p")[0]; 243 var ch_aps = document.getElementsByName("aps")[0]; 244 var ch_clients = document.getElementsByName("clients")[0]; 245 var ch_unlinked = document.getElementsByName("unlinked")[0]; 246 var request = GXmlHttp.create(); 247 var xml_url = "{/literal}{$link_xml_page}{literal}" + 248 (ch_p2p.checked == true?"&show_p2p=1":"") + 249 (ch_aps.checked == true?"&show_aps=1":"") + 250 (ch_clients.checked == true?"&show_clients=1":"") + 251 (ch_unlinked.checked == true?"&show_unlinked=1":""); 252 request.open("GET", xml_url, true); 253 request.onreadystatechange = 254 function() { 255 if (request.readyState == 4) { 256 var xmlDoc = request.responseXML; 257 nodes = xmlDoc.documentElement.getElementsByTagName("node"); 258 links = xmlDoc.documentElement.getElementsByTagName("link"); 259 map.clearOverlays(); 260 markers = Array(); 261 polylines = Array(); 262 gmap_reload(); 263 } 264 } 265 request.send(null); 266 } 267 268 function createMarker(point, html, icon) { 269 var marker = new GMarker(point, icon); 270 GEvent.addListener(marker, "click", 271 function() { 272 marker.openInfoWindowHtml(html); 273 }); 274 275 return marker; 314 map.addOverlays(polylines_t); 276 315 } 277 316 {/literal}
Note: See TracChangeset
for help on using the changeset viewer.
