// file = NodeMarker
var WNMAP_GEOCODE_STATE_ABBR = "OR";
var WNMAP_GEOCODE_STATE_NAME = "Oregon";
var WNMAP_MAP_START_LON = "-122.67133";
var WNMAP_MAP_START_LAT = "45.5231";
var WNMAP_ACCEPTABLE_DISTANCE = "24000";
var WNMAP_MAP_START_ZOOM = "12";
var WNMAP_MAP_START_TYPE = "G_HYBRID_MAP";
var WNMAP_MAP_URL = "http://map.personaltelco.net/";
var WNMAP_NODE_URL = "http://wiki.personaltelco.net/";
//NodeMarker.js
var url;
function NodeMarker (name, description, state, lng, lat, number, website, phone, nocat, down, seen, host, line1, line2, line3, line4, line5, line6, created)
{
this.name = name;
this.description = description;
this.state = state;
this.number = number;
this.website = website;
this.phone = phone;
this.nocat = nocat;
this.down = down;
this.seen = seen;
this.host = host;
this.line1 = line1;
this.line2 = line2;
this.line3 = line3;
this.line4 = line4;
this.line5 = line5;
this.line6 = line6;
this.visible = true;
this.streetAddress = "n/a";
this.tooltip = this.name;
this.lat = lat;
this.lng = lng;
this.created = created;
var point = new GLatLng (lat, lng);
switch (state.toLowerCase()) {
case 'active':
this.statePretty = "Active Node";
var icon = new GIcon (G_DEFAULT_ICON);
//icon.image = WNMAP_MAP_URL + "images/marker_active.png";
icon.sprite = {};
if (this.nocat >= 1) {
icon.sprite.image = WNMAP_MAP_URL + "images/nocat_spr.png";
icon.sprite.top = nocat * 35 - 35;
icon.iconSize = new GSize(35, 35);
icon.imageMap = [0,0, 34,0, 34,34, 0,34];
} else if (this.down == 1 && this.host != '' ) {
icon.sprite.image = WNMAP_MAP_URL + "images/marker_sprite2.png";
icon.sprite.top = 0;
icon.sprite.left = 40;
icon.iconSize = new GSize(20, 34);
} else {
icon.sprite.image = WNMAP_MAP_URL + "images/marker_sprite2.png";
icon.sprite.top = 0;
icon.iconSize = new GSize(20, 34);
}
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(20, 1);
NodeMarker.baseConstructor.call (this, point, icon);
break;
case 'potential':
this.statePretty = "Potential Node";
var icon = new GIcon (G_DEFAULT_ICON);
//icon.image = WNMAP_MAP_URL + "images/marker_potential.png";
icon.sprite = {};
//icon.sprite = {image:"images/marker_sprite.png", width:20, height:34, top:0, left:20}
icon.sprite.image = WNMAP_MAP_URL + "images/marker_sprite.png";
icon.sprite.top = 0;
icon.sprite.left = 20;
icon.iconSize = new GSize(20, 34);
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(20, 1);
NodeMarker.baseConstructor.call (this, point, icon);
break;
case 'marker':
this.statePretty = "Marker";
NodeMarker.baseConstructor.call (this, point);
break;
default:
alert ("Invalid state");
return;
break;
}
this.getOverviewHtml = function () {
var html = "";
if (state == "marker") {
var thing = document.createElement ("div");
thing.className = "marker_balloon";
var title = document.createElement ("div");
title.className = "title";
title.innerHTML = this.name;
thing.appendChild (title);
var renameLink = document.createElement ("a");
renameLink.href = "javascript:var newname = renamePrompt ('" + encode64 (this.name) + "'); if (newname != null) { renameMarker ('" + encode64 (this.name) + "', newname); getMarker (newname).select(); }";
renameLink.innerHTML = "Rename";
title.appendChild (renameLink);
var type = document.createElement ("div");
type.className ="position";
type.innerHTML = "Type: " + this.statePretty;
thing.appendChild (type);
var crt = document.createElement("div");
crt.className = "position";
crt.innerHTML = "Created: " + this.created;
thing.appendChild(crt);
var pos = document.createElement ("div");
pos.className = "position";
pos.innerHTML = "Latitude: " + Math.round(this.getPoint().lat()*1000000)/1000000 + "
Longitude: " + Math.round(this.getPoint().lng()*1000000)/1000000;
thing.appendChild (pos);
var address = document.createElement ("div");
address.className = "position";
address.innerHTML = "Street Address: " + this.streetAddress;
thing.appendChild (address);
var distance = document.createElement ("div");
distance.className = "position";
distance.innerHTML = "Distance to center: " + distanceToCenterPretty(this.getPoint().lat(), this.getPoint().lng());
//thing.appendChild (distance);
var actionList = document.createElement ("ul");
thing.appendChild (actionList);
var addActionItem = document.createElement ("li");
var addActionLink = document.createElement ("a");
addActionLink.innerHTML = "Add this to our database as a location for a potential node.
";
url = WNMAP_MAP_URL + "/AddPotentialNode.php?lon=" + this.getPoint().lng() + "&lat=" + this.getPoint().lat() + "&name=" + URLEncode (this.name) + "&addr='" + encode64 (this.streetAddress) + "'";
addActionLink.href = "javascript:window.open (url, null,'menubar=no,scrollbars=yes,addressbar=no,locationbar=no,status=no,height=530,width=440'); void(0);";
addActionItem.appendChild (addActionLink);
actionList.appendChild (addActionItem);
var deleteActionItem = document.createElement ("li");
var deleteActionLink = document.createElement ("a");
deleteActionLink.innerHTML = "Remove this marker";
deleteActionLink.href = "javascript:getMarker('" + encode64 (this.name) + "').removeMarker ();";
deleteActionItem.appendChild (deleteActionLink);
actionList.appendChild (deleteActionItem);
/*
*/
var f = document.createElement ("div");
f.appendChild (thing);
return f.innerHTML;
} else {
var thing = document.createElement ("div");
thing.className = "marker_balloon";
var title = document.createElement ("div");
var titleImg = document.createElement ("img");
titleImg.src = "http://map.personaltelco.net/images/icon-arrow.gif";
title.appendChild (titleImg);
var titleLink = document.createElement ("a");
titleLink.className = "title";
titleLink.innerHTML = " " + this.name;
titleLink.href = WNMAP_NODE_URL + this.name;
title.appendChild (titleLink);
title.appendChild (document.createTextNode (' (' + this.description + ') '));
thing.appendChild (title);
// Zoom
var zoomLink = document.createElement ("div");
var zoomtoLink = document.createElement ("a");
zoomtoLink.className = "zoomLink";
zoomtoLink.innerHTML = "[+] Zoom in";
zoomtoLink.href = 'javascript:getMarker(\'' + encode64(this.name) + '\').zoomTo()';
zoomLink.appendChild(zoomtoLink);
//zoomLink.appendChild(document.createTextNode (' Zoom in'));
thing.appendChild(zoomLink);
// Display permalink
var linkto = document.createElement ("div");
var linktoLink = document.createElement ("a");
linktoLink.className = "zoomLink";
linktoLink.innerHTML = " Permalink to this location";
linktoLink.href = "http://map.personaltelco.net/?select=" + this.name;
linkto.appendChild (linktoLink);
thing.appendChild (linkto);
// Note if node is down
if (this.down == 1 && this.host != '') {
var nodeDown = document.createElement ("div");
var nodeDownImg = document.createElement ("img");
nodeDownImg.src = "/images/alert.png";
nodeDownImg.display = 'block';
//nodeDown.innerHTML = "This node appears to be down.";
thing.appendChild(nodeDownImg);
thing.appendChild(document.createTextNode(" This node appears to be down. (" + this.seen + ")"));
thing.appendChild(nodeDown);
}
// Display node type (active|potential)
var type = document.createElement ("div");
type.className ="position";
type.innerHTML = "Type: " + this.statePretty;
thing.appendChild (type);
var crt = document.createElement("div");
crt.className = "position";
crt.innerHTML = "Created: " + this.created;
thing.appendChild(crt);
// Display coords
var pos = document.createElement ("div");
pos.className = "position";
pos.innerHTML = "Latitude: " + Math.round(this.getPoint().lat()*1000000)/1000000 + "
Longitude: " + Math.round(this.getPoint().lng()*1000000)/1000000;
thing.appendChild (pos);
// Display street address
var address = document.createElement ("div");
address.className = "position";
address.innerHTML = "Street Address: " + this.streetAddress;
thing.appendChild (address);
// Display phone number
if (this.phone) {
var phone = document.createElement ("div");
phone.className = "position";
phone.innerHTML = "Phone: " + this.phone;
thing.appendChild (phone);
}
// Display NoCat link
if (this.nocat >= "0") {
var nocat = document.createElement ("div");
nocat.innerHTML = "Current Users: " + this.nocat;
thing.appendChild (nocat);
}
// Display Website URL
if (this.website) {
var site = document.createElement ("div");
var siteLink = document.createElement ("a");
siteLink.className = "link";
siteLink.innerHTML = "Website: " + this.website;
siteLink.href = this.website;
site.appendChild (siteLink);
//site.appendChild (document.createTextNode (' (' + this.website + ')'));
thing.appendChild (site);
}
// Display line1+line2 if !null
var line1 = document.createElement ("div");
line1.className = "position";
line1.innerHTML = this.line1;
thing.appendChild (line1);
var line2 = document.createElement ("div");
line2.className = "position";
line2.innerHTML = this.line2;
thing.appendChild (line2);
// Get Directions form
var form = document.createElement ("form");
var directions = document.createElement ("div");
directions.className = "label";
form.action = "http://maps.google.com/maps";
form.method = "GET";
form.target = "_blank";
var directionsLabel = document.createElement ("label");
directionsLabel.htmlFor = "inputSaddr";
directionsLabel.innerHTML = "Start Address: ";
form.appendChild (directionsLabel);
var inputSaddr= document.createElement ("input");
inputSaddr.style.width = "200px";
inputSaddr.style.height = "15px";
inputSaddr.type = "text";
inputSaddr.name = "saddr";
inputSaddr.id = "inputSaddr";
inputSaddr.className = "text";
form.appendChild (inputSaddr);
var submit = document.createElement ("input");
submit.type = "submit";
submit.id = "bump";
submit.className = "label";
submit.value = "Get Directions";
form.appendChild (submit);
// Destination is selected street address
var inputDaddr = document.createElement ("input");
inputDaddr.type = "hidden";
inputDaddr.name = "daddr";
inputDaddr.value = this.streetAddress;
form.appendChild (inputDaddr);
directions.appendChild (form);
thing.appendChild (directions);
// End Get Directions
//var distance = document.createElement ("div");
//distance.className = "position";
//distance.innerHTML = "Distance to center: " + distanceToCenterPretty(this.getPoint().lat(), this.getPoint().lng());
//thing.appendChild (distance);
var f = document.createElement ("div");
f.appendChild (thing);
return f.innerHTML;
}
}
this.getImageHtml = function () {
var thing = document.createElement ("div");
thing.className = "marker_balloon";
var f = document.createElement ("div");
var photo = document.createElement ("div");
var photoLink = document.createElement ("a");
photoLink.className = "imagelink";
photoLink.href = this.line4;
photoLink.target = "_blank";
var line4Link = document.createElement ("img");
line4Link.className = "photo";
line4Link.src = this.line4;
line4Link.height = "120";
photoLink.appendChild (line4Link);
photo.appendChild (photoLink);
var photo5Link = document.createElement ("a");
photo5Link.href = this.line5;
photo5Link.target = "_blank";
var line5Link = document.createElement ("img");
line5Link.src = this.line5;
line5Link.height = "120";
photo5Link.appendChild (line5Link);
photo.appendChild (photo5Link);
thing.appendChild (photo);
return thing;
}
// New streeview; no api
this.getStreetViewHtml = function () {
var thing = document.createElement ("div");
thing.className = "marker_balloon";
thing.innerHTML = '';
return thing;
}
this.getNoCatHtml = function () {
var user = document.createElement ("div");
user.className = "marker_balloon";
user.innerHTML = '
