summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@ffgraz.net>2008-12-06 09:48:44 +0000
committerChristian Pointner <equinox@ffgraz.net>2008-12-06 09:48:44 +0000
commit551c3222b65f5c68d2e0e45ddff7c5e814316ed1 (patch)
treef7bbd520bd452dfd7df1d3a45079f2553fdbef30
parent61448e4c2aabaf06cdae4160de77aaac8c7ad692 (diff)
added drawLocations
-rw-r--r--data.php25
-rw-r--r--map.js45
2 files changed, 57 insertions, 13 deletions
diff --git a/data.php b/data.php
index 97e59b4..b5c0b51 100644
--- a/data.php
+++ b/data.php
@@ -59,6 +59,7 @@ while ($data = $db->getNextObject()) {
$data->lng = $lng_startpoint + ($data->pixel_x - $x_startpoint) / $dx_dLng;
$data->lat = $lat_startpoint + ($y_startpoint - $data->pixel_y) / $dy_dLat;
+ $data->state = "offline";
$locations[$data->locid] = $data;
}
@@ -97,6 +98,19 @@ foreach ($lines as $num => $line)
$links[$i]->ipfromLoc = $ipfromLoc;
$links[$i]->iptoLoc = $iptoLoc;
$links[$i]->label = $label;
+ if($locations[$locids[$ipfromLoc]]->state == "offline")
+ $locations[$locids[$ipfromLoc]]->state = "online";
+ if($locations[$locids[$iptoLoc]]->state == "offline")
+ $locations[$locids[$iptoLoc]]->state = "online";
+
+ if (($nodename[$ipfromLoc] == "tunnel" && $locations[$locids[$ipfromLoc]]->locname=="housing") ||
+ ($nodename[$iptoLoc] == "tunnel" && $locations[$locids[$iptoLoc]]->locname=="housing" ) ||
+ ($locations[$locids[$iptoLoc]]->hastinc && $locations[$locids[$ipfromLoc]]->hastinc)) {
+ $link->label = -1;
+ $locations[$locids[$ipfromLoc]]->state = "tunnel";
+ $locations[$locids[$iptoLoc]]->state = "tunnel";
+ }
+
$i++;
}
}
@@ -108,21 +122,14 @@ echo "<root>\n";
echo "<nodes>\n";
foreach ($locations as $location) {
$data = $locations[$location->locid];
- printf("\t" . '<node id="%s" name="%s" lat="%s" lng="%s" pixel_x="%s" pixel_y="%s" gallery_link="%s"/>' . "\n",
- $data->locid, $data->locname, $data->lat, $data->lng, $data->pixel_x, $data->pixel_y, $data->gallery_link);
+ printf("\t" . '<node id="%s" name="%s" lat="%s" lng="%s" pixel_x="%s" pixel_y="%s" state="%s" gallery_link="%s"/>' . "\n",
+ $data->locid, $data->locname, $data->lat, $data->lng, $data->pixel_x, $data->pixel_y, $data->state, $data->gallery_link);
}
echo "</nodes>\n";
echo "<links>\n";
foreach ($links as $link)
{
- if (($nodename[$link->ipfromLoc] == "tunnel" && $locations[$locids[$link->ipfromLoc]]->locname=="housing") ||
- ($nodename[$link->iptoLoc] == "tunnel" && $locations[$locids[$link->iptoLoc]]->locname=="housing" ))
- $link->label = -1;
-
- if ($locations[$locids[$link->iptoLoc]]->hastinc && $locations[$locids[$link->ipfromLoc]]->hastinc)
- $link->label = -1;
-
$data1 = $locations[$locids[$link->ipfromLoc]];
$data2 = $locations[$locids[$link->iptoLoc]];
diff --git a/map.js b/map.js
index e264429..bd03cc0 100644
--- a/map.js
+++ b/map.js
@@ -1,10 +1,11 @@
var map = null;
var physicalMaxLevel;
-var xmlData = null;
var geocoder = null;
var overlays = new Array();
overlays["newmarker"] = null;
overlays["ruler"] = new Array();
+overlays["locations"] = new Array();
+var locations = new Array();
function initialize(lat, lng, res) {
if (!checkBrowser()) {
@@ -42,7 +43,7 @@ function initialize(lat, lng, res) {
geocoder = new GClientGeocoder();
-// GDownloadUrl("data.php", onData);
+ GDownloadUrl("data.php", onData);
}
function checkBrowser() {
@@ -59,6 +60,7 @@ function checkBrowser() {
function onAddOverlay(overlay) {
switch(overlay.overlaytype) {
+ case "location": overlays["locations"].push(overlay); break;
case "newmarker": {
if(overlays["newmarker"]) {
map.removeOverlay(overlays["newmarker"]);
@@ -96,7 +98,39 @@ function onData(data, responseCode) {
}
xmlData = GXml.parse(data);
- // TODO: add data import and comment in GDownloadUrl() at initialize()
+ for(var loc in overlays["locations"]) {
+ map.removeOverlay(overlays["locations"][loc]);
+ }
+ overlays["locations"] = [];
+ locations = [];
+ drawLocations(xmlData);
+}
+
+function drawLocations(xmlData) {
+ var element = xmlData.getElementsByTagName("node");
+ for (var i = 0; i< element.length; i++) {
+ var id = parseInt(element[i].getAttribute("id"));
+ locations[id] = new Location(element[i]);
+
+ var marker = new GMarker(locations[id].point, {icon: makeIcon(locations[id].state)});
+ marker.overlaytype = "location";
+ marker.locid = id;
+ map.addOverlay(marker);
+ }
+}
+
+function Location(element) {
+ var location = new Object();
+ location.name = element.getAttribute("name");
+ var lat = parseFloat(element.getAttribute("lat"));
+ var lng = parseFloat(element.getAttribute("lng"));
+ location.point = new GLatLng(lat, lng);
+ location.pixel_x = parseInt(element.getAttribute("pixel_x"));
+ location.pixel_y = parseInt(element.getAttribute("pixel_y"));
+ location.state = element.getAttribute("state");
+ location.gallery_link = element.getAttribute("gallery_link");
+
+ return location;
}
function addNewNodeText(point) {
@@ -109,7 +143,10 @@ function makeIcon(type) {
switch(type) {
case 'ruler': icon.image = "./img/marker_blue.png"; break;
- case 'newnode': icon.image = "./img/marker_darkred.png";
+ case 'newnode': icon.image = "./img/marker_darkred.png"; break;
+ case 'online': icon.image = "./img/marker_online.png"; break;
+ case 'tunnel': icon.image = "./img/marker_tunnel.png"; break;
+ case 'offline': icon.image = "./img/marker_offline.png"; break;
}
icon.iconSize = new GSize(12,20);
icon.iconAnchor = new GPoint(6,20);