// 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 = '
'; return user; } this.getClientHtml = function () { var client = document.createElement ("div"); client.className = "marker_balloon"; client.innerHTML = '' + this.description + '
'; return client; } // Old streetview, boring interface //this.getStreetViewHtml = function () { // var thing = document.createElement ("div"); // thing.className = "marker_balloon"; // client = new GStreetviewClient(); // var f = document.createElement ("div"); // thing.innerHTML = ""; // var street = document.createElement ("div"); // street.id = "pano"; // street.name = "pano"; // street.style.width = "425px"; // street.style.height = "240px"; // thing.appendChild (street); // return thing; //} function DistanceCalculator (node) { this.node = node; var overlay = null; //GEvent.addListener (map, "infowindowclose", function () { // map.removeOverlay(overlay); //}); this.getContent = function() { var select = document.createElement ("select"); select.style.width = "200px"; var option = document.createElement("option"); option.appendChild(document.createTextNode("- select -")); select.appendChild(option); var activegroup = document.createElement("optgroup"); activegroup.label = "Active nodes" var inactivegroup = document.createElement("optgroup"); inactivegroup.label = "Potential Nodes"; var markergroup = document.createElement("optgroup"); markergroup.label = "My Markers"; for (key in markers) { var marker = markers[key]; if (marker != node) { option = document.createElement("option"); option.appendChild(document.createTextNode(marker.name)); if (marker.state == "active") { activegroup.appendChild(option); } else if (marker.state == "marker") { markergroup.appendChild(option); } else { inactivegroup.appendChild(option); } } } if (markergroup.childNodes.length > 0) { select.appendChild(markergroup); } if (activegroup.childNodes.length > 0) { select.appendChild(activegroup); } if (inactivegroup.childNodes.length > 0) { select.appendChild(inactivegroup); } var container = document.createElement ("div"); var text = document.createElement ("span"); text.innerHTML = "Distance Calculator
" + this.node.name + " to
"; container.appendChild (text); container.appendChild (select); var result = document.createElement("p"); result.style.setProperty ("font-size", "large", ""); result.style.setProperty ("margin-bottom", "0px", ""); result.style.setProperty ("margin-top", "10px", ""); container.appendChild (result); select.onchange = function () { if (overlay != null) { map.removeOverlay(overlay); } for (key in markers) { var otherMarker = markers[key]; if (otherMarker.name == select.value) { var meters = node.getPoint().distanceFrom (otherMarker.getPoint()); var yards = meters * 1.0936; var feet = meters * 3.2808; var km = meters / 1000; var miles = km * 0.6214; if (km > 2) { result.innerHTML = roundNumber(km,2) + " km"; } else { result.innerHTML = roundNumber(meters,2) + " meters"; } result.innerHTML += "
"; if (miles > 1) { result.innerHTML += roundNumber(miles,2) + " miles"; } else { result.innerHTML += roundNumber(yards,2) + " yards"; result.innerHTML += "
"; result.innerHTML += roundNumber(feet,2) + " feet"; } overlay = new GPolyline([node.getPoint(), otherMarker.getPoint()], "#FF8000", 10 ); map.addOverlay(overlay); return; } } result.innerHTML = ""; } return container; } } function roundNumber(num, dec) { var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); return result; } this.getCactiNetHtml = function () { var thing = document.createElement ("div"); thing.className = "marker_balloon"; var f = document.createElement ("div"); var net = document.createElement ("div"); //net.innerHTML = "Click graph to enlarge
"; var netLink = document.createElement ("a"); netLink.href = this.line6; netLink.target = "_blank"; var line6Link = document.createElement ("img"); line6Link.src = this.line6; line6Link.height = "140"; netLink.appendChild (line6Link); net.appendChild (netLink); thing.appendChild (net); return thing; } this.setStreetAddress = function (addr) { this.streetAddress = addr; } this.select = function () { //var infoTabs; //map.closeInfoWindow(infoTabs); if (this.nocat >= "1") { var infoTabs = [ new GInfoWindowTab("Overview", this.getOverviewHtml()), new GInfoWindowTab("History", this.getNoCatHtml()), new GInfoWindowTab("Users", this.getClientHtml()), new GInfoWindowTab("Street View", this.getStreetViewHtml()), new GInfoWindowTab("Distance", new DistanceCalculator(this).getContent()) ]; } else if (this.host) { var infoTabs = [ new GInfoWindowTab("Overview", this.getOverviewHtml()), new GInfoWindowTab("History", this.getNoCatHtml()), new GInfoWindowTab("Street View", this.getStreetViewHtml()), new GInfoWindowTab("Distance", new DistanceCalculator(this).getContent()) ]; } else { var infoTabs = [ new GInfoWindowTab("Overview", this.getOverviewHtml()), new GInfoWindowTab("Street View", this.getStreetViewHtml()), new GInfoWindowTab("Distance", new DistanceCalculator(this).getContent()) ]; } this.openInfoWindowTabs (infoTabs); document.getElementById("coordView").innerHTML = this.getPoint().lat() + " " + this.getPoint().lng(); document.getElementById("addr").innerHTML = this.streetAddress + " | "; } this.zoomTo = function () { this.hideTooltip (); map.setCenter (this.getPoint(), 19); if (this.nocat >= "1") { var infoTabs = [ new GInfoWindowTab("Overview", this.getOverviewHtml()), new GInfoWindowTab("History", this.getNoCatHtml()), new GInfoWindowTab("Users", this.getClientHtml()), new GInfoWindowTab("Street View", this.getStreetViewHtml()), new GInfoWindowTab("Distance", new DistanceCalculator(this).getContent()) ]; } else if (this.host) { var infoTabs = [ new GInfoWindowTab("Overview", this.getOverviewHtml()), new GInfoWindowTab("History", this.getNoCatHtml()), new GInfoWindowTab("Street View", this.getStreetViewHtml()), new GInfoWindowTab("Distance", new DistanceCalculator(this).getContent()) ]; } else { var infoTabs = [ new GInfoWindowTab("Overview", this.getOverviewHtml()), new GInfoWindowTab("Street View", this.getStreetViewHtml()), new GInfoWindowTab("Distance", new DistanceCalculator(this).getContent()) ]; } this.openInfoWindowTabs (infoTabs); } // In GMap2, the maps API changed sufficiently to break the original // tooltip code contained here. As a part of the port to GMap2, I'd // like to thank toEat.com and Robert Aspinall for doing the heavy // lifting in that code. It showed the way for how to re-implement // tooltips in GMap2. this.showTooltip = function () { if (this.tooltip) { if (!this.tooltipObject) { this.tooltipObject = document.createElement ('div'); this.tooltipObject.innerHTML = this.name; var opacity = .90; this.tooltipObject.className ="tooltip"; this.tooltipObject.style.position = 'relative'; this.tooltipObject.style.background = 'white'; //this.tooltipObject.style.background = 'white url(images/arrow.gif) no-repeat 50px 50px'; this.tooltipObject.style.background = 'url(/images/tail.png) bottom left no-repeat'; //this.tooltipObject.style.border = '1px solid black'; this.tooltipObject.style.height = '42px'; //this.tooltipObject.style.padding = '2px'; this.tooltipObject.style.padding = '4px 12px 1px 17px'; this.tooltipObject.style.zIndex = 50000; this.tooltipObject.style.clear = 'both'; this.tooltipObject.style.filter = "alpha(opacity=" + opacity + ")"; this.tooltipObject.style.opacity = opacity; this.tooltipObject.style.MozBorderRadius = '6px 6px 6px 0'; map.getPane(G_MAP_MARKER_PANE).appendChild(this.tooltipObject); } var c = map.fromLatLngToDivPixel(new GLatLng(this.getPoint().lat(), this.getPoint().lng())); try { this.tooltipObject.style.top = c.y - ( this.getIcon().iconAnchor.y + 23 ) + "px"; this.tooltipObject.style.left = c.x + ( this.getIcon().iconSize.width - this.getIcon().iconAnchor.x - 5 ) + "px"; this.tooltipObject.style.display = "block"; } catch(e) { alert(e); } } } this.hideTooltip = function () { if (this.tooltipObject) { this.tooltipObject.style.display = "none"; } } this.removeMarker = function () { this.hideTooltip (); delete markers[this.name]; populateMap (); } GEvent.addListener (this, 'click', this.select); GEvent.addListener (this, 'mouseover', this.showTooltip); GEvent.addListener (this, 'mouseout', this.hideTooltip); } extend = function(subClass, baseClass) { function inheritance() {} inheritance.prototype = baseClass.prototype; subClass.prototype = new inheritance(); subClass.prototype.constructor = subClass; subClass.baseConstructor = baseClass; subClass.superClass = baseClass.prototype; } extend(NodeMarker, GMarker);