//required for all scripts //document.domain = "angling-technologies.com"; var baseurl = '/atom/lib/AnglingTech/'; var $id = OpenLayers.Util.getElement; var map, layerlist, basictoolbar_panel, currentdiv, popup, identify, weather, email, poi, poiprivate,updateSample,maponmypage,print,tempmarkers,exportpoints; var subscribe_ctl,weather_ctl,emailextent_ctl,search_ctl,help_ctl, login_ctl,points_ctl,extents_ctl,gps_ctl,register_ctl,identify_ctl,addpoint_ctl,espn_ctl,mymap_ctl,editpoint_ctl; var intro_ctl,splash_ctl; var cent = new OpenLayers.LonLat(-11036039, 4866971); var isloggedin = true; var showmymap = false; var adctr; var lastmarker; var poiclick; var userid = null; if(document.location.href.indexOf('mymap') > 0){ showmymap = true; } AutoSizeAnchoredBubble = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, {'autoSize': true, 'backgroundColor': 'black'}); OLMiniMapPermalink = OpenLayers.Class(OpenLayers.Control.Permalink, { draw: function() { OpenLayers.Control.Permalink.prototype.draw.apply(this, arguments); if (this.element) { this.element.innerHTML = "Angling Technologies click to see full map"; } return this.div; }, updateLink: function() { var href = this.base; if (href.indexOf('?') != -1) { href = href.substring( 0, href.indexOf('?') ); } href += '?' + OpenLayers.Util.getParameterString(this.createParams()); this.element.href = "javascript:gotofullview()"; } }); OLAnglingMousePosition = OpenLayers.Class(OpenLayers.Control.MousePosition, { formatCoords: function (base) { var t, t2; if(base > 0){ var degrees = Math.floor(base); var minutes = Math.floor(t = ( base - degrees ) * 60); var seconds = Math.floor(t2 = ( t - minutes ) * 6000); var decimalminutes = t / 100.00; }else{ var degrees = Math.ceil(base); var minutes = Math.ceil(t = ( base - degrees ) * 60); var seconds = Math.ceil(t2 = ( t - minutes ) * 6000); var decimalminutes = t / 100.00; } var digits = parseInt(this.numdigits); minutes = t; //minutes = minutes / 100.00; //return ("" + degrees + "\u00B0 " + minutes + "\u0027 " +t + "\u0022") return ("" + degrees + "\u00B0 " + minutes.toFixed(this.numdigits) + "\u0027") }, formatOutput: function(lonLat) { var newHtml = this.prefix + this.formatCoords(lonLat.lon) + this.separator + this.formatCoords(lonLat.lat); return newHtml; } }); POIAddClick = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: {'active':false,'single':true,'double':false,'pixelTolerance':0,'stopSingle':false,'stopDouble':false}, initialize: function(options) {this.handlerOptions = OpenLayers.Util.extend({}, this.defaultHandlerOptions);OpenLayers.Control.prototype.initialize.apply(this, arguments);this.handler = new OpenLayers.Handler.Click(this,{'click': this.trigger},this.handlerOptions);}, trigger: function(e) { if (!this.active){ return false; } if(e == undefined){ return false; } if (isloggedin){ var lonlat; if(e.xy != null){ lonlat = map.getLonLatFromViewPortPx(e.xy); } //alert("You clicked near " + lonlat.lat + " N, " + lonlat.lon + " E"); //var markers = new OpenLayers.Layer.Markers("Markers"); //map.addLayer(markers); var size = new OpenLayers.Size(15,15); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon('/atom/lib/AnglingTech/img/symbols/icon_pushpin.png',size,offset); //var pt = new OpenLayers.LonLat(-71.05,42.3).transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913")) var pt = new OpenLayers.LonLat(lonlat.lon,lonlat.lat); var newmarker = new OpenLayers.Marker(pt,icon); lastmarker = newmarker; poiprivate.addMarker(newmarker); var newpoint = new OpenLayers.LonLat(lonlat.lon, lonlat.lat).transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); var px = new OpenLayers.Pixel(300,300); var ct = map.getLonLatFromLayerPx(px); var url = baseurl + 'php/addpoint.php?point='+newpoint.lon+','+newpoint.lat; destroycontrol(emailextent_ctl); destroycontrol(intro_ctl); destroycontrol(extents_ctl); destroycontrol(login_ctl); destroycontrol(register_ctl); destroycontrol(addpoint_ctl); addpoint_ctl = new OpenLayers.Control.ATPopupControl({'top':125,'left':240,'width':400,'url':url}); map.addControl(addpoint_ctl); addpoint_ctl.maximizeControl(); /* OpenLayers.loadURL(, '', this, function (response) { if (popup) { popup.destroy(); popup = null; } popup = new AutoSizeAnchoredBubble("findwindow",ct, new OpenLayers.Size(400, 400),response.responseText, null, true); map.addPopup(popup); popup.setBackgroundColor('black'); OpenLayers.Rico.Corner.changeOpacity(popup.div,.90); } ); */ }else { login(); } } } ); PCPanel = OpenLayers.Class(OpenLayers.Control.Panel, { activateControl: function (control) { if (!this.active) return false; if (control.type == OpenLayers.Control.TYPE_BUTTON) { control.activate(); control.trigger(); this.redraw(); } if (control.type == OpenLayers.Control.TYPE_TOGGLE) { if (control.active) control.deactivate(); else control.activate(); this.redraw(); return; } for (var i=0, len=this.controls.length; i2"; } element.innerHTML = out; } function setHTML(response){ var element = document.getElementById("ads") element.innerHTML = response.responseText; } function getads(){ var mymap = 0; //update adcenter adctr = map.center.clone(); adctr.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); if(!showmymap){ espnad(); mymap = 0; }else{ mymap = 1; } var box = map.getExtent().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")).toBBOX(); //var box = map.getExtent().toBBOX(); var zoom = map.zoom; var url = baseurl + 'php/getads.php?b='+box+'&z='+zoom+'&mymap='+mymap; OpenLayers.loadURL(url, '', this, setHTML); } function espnad(){ /* if(!showmymap){ var box = map.getExtent().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")).toBBOX(); var zoom = map.zoom; var url = baseurl + 'php/espn-getads.php?box='+box+'&zoom='+zoom; if(!espn_ctl){ espn_ctl = new OpenLayers.Control.ATAdControl({'top':3,'left':335,'width':400,'url':url}); map.addControl(espn_ctl); espn_ctl.maximizeControl(); }else{ espn_ctl.redraw(url); } } */ } function advertise(){ var ctr = map.center.clone(); ctr.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); var zoomlevel = map.zoom; var url = 'http://ads.angling-technologies.com/account.php?zoom='+zoomlevel+'&lat='+ctr.lat+'&lon='+ctr.lon; url = 'http://ads.angling-technologies.com/'; window.open(url,'Advertise','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=900,height=500,left=100,top=100'); } function addtextmarkerprivate(ilon, ilat, itext, ifontsize, ifontcolor, iwhitespace, ibackgroundcolor, iborder, ibordercolor) { var lonlat = new OpenLayers.LonLat(ilon, ilat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); var iborderstyle="hidden"; if (iborder=="thin") iborderstyle="solid"; var options = { style: { 'fontSize': ifontsize, 'color': ifontcolor, 'whiteSpace': iwhitespace, 'backgroundColor': ibackgroundcolor, 'border': iborder, 'borderColor': ibordercolor, 'borderStyle': iborderstyle, 'padding': '4px' } } //options.style.fontSize = ifontsize; latlon = new OpenLayers.LonLat(lonlat.lon, lonlat.lat); anno = new OpenLayers.Marker.Annotation(itext, latlon, null, options); poiprivate.addMarker(anno); } function addpoi(ilon, ilat,type){ var lonlat = new OpenLayers.LonLat(ilon, ilat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); var size; var icon; switch(type){ case 'business': size = new OpenLayers.Size(22,18); icon = new OpenLayers.Icon('/atom/lib/AnglingTech/img/symbols/lodge_22_18.png',size,offset); break; case 'personal': size = new OpenLayers.Size(19,18); icon = new OpenLayers.Icon('/atom/lib/AnglingTech/img/symbols/poi_19_18.png',size,offset); break; default: size = new OpenLayers.Size(19,18); icon = new OpenLayers.Icon('/atom/lib/AnglingTech/img/symbols/poi_19_18.png',size,offset); } var offset = new OpenLayers.Pixel(0, 0); var pt = new OpenLayers.LonLat(lonlat.lon,lonlat.lat); poi.addMarker(new OpenLayers.Marker(pt,icon.clone())); } function addpoiprivate(ilon, ilat){ var lonlat = new OpenLayers.LonLat(ilon, ilat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); var size = new OpenLayers.Size(19,18); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon('/atom/lib/AnglingTech/img/symbols/poi_19_18.png',size,offset); var pt = new OpenLayers.LonLat(lonlat.lon,lonlat.lat); poiprivate.addMarker(new OpenLayers.Marker(pt,icon.clone())); } // Finds elements by class name. // Needed to re-style and inject html into OL code that lacks proper element ids function getElementsByClass(searchClass,node,tag) { var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\\\s)"+searchClass+""); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; } function getlegend(layername) { thelegendimage = ''; switch (layername) { case "Waypoints": thelegendimage = ''; break; case "POI (Public)": thelegendimage = ''; break; case "Structure": thelegendimage = ''; break; case "Fishing Spots": thelegendimage = ''; break; case "Gulf Platforms": thelegendimage = ''; break; case "Gulf Pipelines": thelegendimage = ''; break; case "Depth Contours": thelegendimage = ''; break; case "Depth Profiles": thelegendimage = ''; break; case "B & W Imagery": thelegendimage = ''; break; case "Charts": thelegendimage = ''; break; case "Topo Map": thelegendimage = ''; break; case "NOAA": thelegendimage = ''; break; default: thelegendimage = ''; break; } return thelegendimage; } //check if the next sibling node is an element node function get_nextsibling(theNode) { x=theNode.nextSibling; while (x.nodeType!=1) { x=x.nextSibling; } return x; } function injectLayerListLegend() { var layerListIdPrefix = "OpenLayers.Control.LayerSwitcher_45_input_"; var legendList = [ document.getElementById(layerListIdPrefix+"Topo Map"), //document.getElementById(layerListIdPrefix+"B & W Imagery"), document.getElementById(layerListIdPrefix+"Depth Profiles"), document.getElementById(layerListIdPrefix+"NOAA"), document.getElementById(layerListIdPrefix+"Depth Contours"), document.getElementById(layerListIdPrefix+"Gulf Platforms"), document.getElementById(layerListIdPrefix+"Gulf Pipelines"), document.getElementById(layerListIdPrefix+"Fishing Spots"), document.getElementById(layerListIdPrefix+"Structure"), document.getElementById(layerListIdPrefix+"POI (Public)") ]; for (var i = 0; i < legendList.length; i++ ) { //var x = document.getElementById("OpenLayers.Control.LayerSwitcher_45_input_Structure"); /* // NorthCol - work in progress: show/hide legend area... newel = document.createElement("div"); newel.id = "lll_"+legendList[i].name; newel.name = "lll_"+legendList[i].name; if (!layerSpan.checked) { newel.setAttribute("style", "display: none; visibility: hidden;"); } else { newel.setAttribute("style", "display: block; visibility: visible;"); } newel.innerHTML = getlegend(legendList[i].name); get_nextsibling(layerSpan).appendChild(newel); newanchor = document.createElement("a"); newanchor.setAttribute("href", "javascript:atomShowLegend('"+legendList[i].name+"');"); newanchor.setAttribute("title", "show/hide legend"); if (!layerSpan.checked) { newanchor.innerHTML = 'show legend'; } else { newanchor.innerHTML = 'hide legend'; } layerSpan.parentNode.insertBefore(newanchor, layerSpan); */ var layerSpan = legendList[i]; if (!layerSpan.checked) { // don't display if not visible } else { newlllegend = document.createElement("span"); newlllegend.id = "lll_"+legendList[i].name; newlllegend.name = "lll_"+legendList[i].name; newlllegend.setAttribute("style", "display: inline;visibility:visible;float:right;"); newlllegend.innerHTML = getlegend(legendList[i].name); layerSpan.parentNode.insertBefore(newlllegend, layerSpan); } } } function clickbanner(){ } function introtab(tabid){ for(i=0;i<20;i++){ //reset content el = document.getElementById('intro_'+i); if(el != null){ el.style.display = 'none'; } //reset button el = document.getElementById('introbutton_'+i); if(el != null){ el.className = 'introbutton'; } } el = document.getElementById('intro_'+tabid); el.style.display = ''; el = document.getElementById('introbutton_'+tabid); if(el != null){ el.className = 'introselected'; } } function showSplash(){ if(!readCookie('at_nosplash')){ var splash = document.getElementById('splashscreen'); var splashWrap = document.getElementById('splashwrap'); splash.style.display="block"; splashWrap.style.display="block"; OpenLayers.Util.setOpacity(splashWrap,0.75); } } function hideSplash(){ var splash = document.getElementById('splashscreen'); var splashWrap = document.getElementById('splashwrap'); splash.style.display="none"; splashWrap.style.display="none"; } function stopSplash(){ createCookie('at_nosplash','true',365); } function stopInstantHelp(){ createCookie('at_nohelp','true',365); } function gotofullview(){ //alert('going to ' + permalink.element.href); parent.location.href = permalink.element.href.replace('mymap=1',''); } /* * After a successful add point operation * refresh the visible point wms layers */ function refreshPointLayers(){ var ptWms = ['Waypoints','POI (Public)','Fishing Spots']; for(var i=0,len=map.layers.length;i-1){ lyr.redraw(true); } } } /*auto activate layers at correct zoom levels if a layer is autoactivated then pop open the layer control panel if it is not already open called with 'map' as scope */ function activateLayers(evt){ var map = this; var layers = map.layers; var activated = false; //loop through layers, if layer has 'autoActivate' property //turn it on if autoActivate level is >= current map zoom for(var i=0,len=layers.length;i=lyr.autoActivate){ lyr.setVisibility(true) activated = true; } } //if layer control is not open then open it var lyrCtrl = showlayers; if(activated && !lyrCtrl.active){lyrCtrl.trigger();} } function onBaseLayerChange(evtObj){ var mapProj, baseProj, map, newBase, reproject; map = this; newBase = evtObj.layer; mapProj = (map.projection && map.projection instanceof OpenLayers.Projection) ? map.projection : new OpenLayers.Projection(map.projection); baseProj = newBase.projection; reproject = !(baseProj.equals(mapProj)); if (reproject) { var center, maxExt; //calc proper reporojected center center = map.getCenter().transform(mapProj, baseProj); //calc correct reprojected extents maxExt = newBase.maxExtent; //set map projection, extent, & center of map to proper values map.projection = baseProj; map.maxExtent = maxExt; map.setCenter(center); } } function initmap() { /* originals var mapfile = "http://mapper.angling-technologies.com/cgi-bin/mapserv?map=/usr/local/www/htdocs/anglingtech/data/mapper2.map"; var mapfile2 = "http://mapper.angling-technologies.com/cgi-bin/mapserv?map=/usr/local/www/htdocs/paragon.angling-technologies.com/paragon.map"; */ //var mapfile = "http://mapserver.angling-technologies.com/cgi-bin/mapserv?map=/usr/local/mapdata/maps/atom.map"; //var mapfile = "http://mapserver.angling-technologies.com/tileserver.php"; Proj4js.defs["EPSG:102113"] = Proj4js.defs["EPSG:900913"]; var tcPath = "tilecache/tilecache.cgi/1/"; var mapfilePath = "map=/usr/local/mapdata/maps/atom_test.map"; var subdomains = ["mapserver","ms1","ms2","ms3","ms4","ms5"]; var mapfile2 = function(){ var urls = [] for(var i=0,len=subdomains.length;i