text: /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
   * full list of contributors). Published under the 2-clause BSD license.
   * See license.txt in the OpenLayers distribution or repository for the
   * full text of the license. */
  
  OpenLayers.Layer=OpenLayers.Class({id:null,name:null,div:null,opacity:1,alwaysInRange:null,RESOLUTION_PROPERTIES:["scales","resolutions","maxScale","minScale","maxResolution","minResolution","numZoomLevels","maxZoomLevel"],events:null,map:null,isBaseLayer:!1,alpha:!1,displayInLayerSwitcher:!0,visibility:!0,attribution:null,inRange:!1,imageSize:null,options:null,eventListeners:null,gutter:0,projection:null,units:null,scales:null,resolutions:null,maxExtent:null,minExtent:null,maxResolution:null,minResolution:null,numZoomLevels:null,minScale:null,maxScale:null,displayOutsideMaxExtent:!1,wrapDateLine:!1,metadata:null,initialize:function(e,t){this.metadata={},t=OpenLayers.Util.extend({},t),this.alwaysInRange!=null&&(t.alwaysInRange=this.alwaysInRange),this.addOptions(t),this.name=e,this.id==null&&(this.id=OpenLayers.Util.createUniqueID(this.CLASS_NAME+"_"),this.div=OpenLayers.Util.createDiv(this.id),this.div.style.width="100%",this.div.style.height="100%",this.div.dir="ltr",this.events=new OpenLayers.Events(this,this.div),this.eventListeners instanceof Object&&this.events.on(this.eventListeners))},destroy:function(e){e==null&&(e=!0),this.map!=null&&this.map.removeLayer(this,e),this.projection=null,this.map=null,this.name=null,this.div=null,this.options=null,this.events&&(this.eventListeners&&this.events.un(this.eventListeners),this.events.destroy()),this.eventListeners=null,this.events=null},clone:function(e){return e==null&&(e=new OpenLayers.Layer(this.name,this.getOptions())),OpenLayers.Util.applyDefaults(e,this),e.map=null,e},getOptions:function(){var e={};for(var t in this.options)e[t]=this[t];return e},setName:function(e){e!=this.name&&(this.name=e,this.map!=null&&this.map.events.triggerEvent("changelayer",{layer:this,property:"name"}))},addOptions:function(e,t){this.options==null&&(this.options={}),e&&(typeof e.projection=="string"&&(e.projection=new OpenLayers.Projection(e.projection)),e.projection&&OpenLayers.Util.applyDefaults(e,OpenLayers.Projection.defaults[e.projection.getCode()]),e.maxExtent&&!(e.maxExtent instanceof OpenLayers.Bounds)&&(e.maxExtent=new OpenLayers.Bounds(e.maxExtent)),e.minExtent&&!(e.minExtent instanceof OpenLayers.Bounds)&&(e.minExtent=new OpenLayers.Bounds(e.minExtent))),OpenLayers.Util.extend(this.options,e),OpenLayers.Util.extend(this,e),this.projection&&this.projection.getUnits()&&(this.units=this.projection.getUnits());if(this.map){var n=this.map.getResolution(),r=this.RESOLUTION_PROPERTIES.concat(["projection","units","minExtent","maxExtent"]);for(var i in e)if(e.hasOwnProperty(i)&&OpenLayers.Util.indexOf(r,i)>=0){this.initResolutions(),t&&this.map.baseLayer===this&&(this.map.setCenter(this.map.getCenter(),this.map.getZoomForResolution(n),!1,!0),this.map.events.triggerEvent("changebaselayer",{layer:this}));break}}},onMapResize:function(){},redraw:function(){var e=!1;if(this.map){this.inRange=this.calculateInRange();var t=this.getExtent();if(t&&this.inRange&&this.visibility){var n=!0;this.moveTo(t,n,!1),this.events.triggerEvent("moveend",{zoomChanged:n}),e=!0}}return e},moveTo:function(e,t,n){var r=this.visibility;this.isBaseLayer||(r=r&&this.inRange),this.display(r)},moveByPx:function(e,t){},setMap:function(e){if(this.map==null){this.map=e,this.maxExtent=this.maxExtent||this.map.maxExtent,this.minExtent=this.minExtent||this.map.minExtent,this.projection=this.projection||this.map.projection,typeof this.projection=="string"&&(this.projection=new OpenLayers.Projection(this.projection)),this.units=this.projection.getUnits()||this.units||this.map.units,this.initResolutions();if(!this.isBaseLayer){this.inRange=this.calculateInRange();var t=this.visibility&&this.inRange;this.div.style.display=t?"":"none"}this.setTileSize()}},afterAdd:function(){},removeMap:function(e){},getImageSize:function(e){return this.imageSize||this.tileSize},setTileSize:function(e){var t=e?e:this.tileSize?this.tileSize:this.map.getTileSize();this.tileSize=t,this.gutter&&(this.imageSize=new OpenLayers.Size(t.w+2*this.gutter,t.h+2*this.gutter))},getVisibility:function(){return this.visibility},setVisibility:function(e){e!=this.visibility&&(this.visibility=e,this.display(e),this.redraw(),this.map!=null&&this.map.events.triggerEvent("changelayer",{layer:this,property:"visibility"}),this.events.triggerEvent("visibilitychanged"))},display:function(e){e!=(this.div.style.display!="none")&&(this.div.style.display=e&&this.calculateInRange()?"block":"none")},calculateInRange:function(){var e=!1;if(this.alwaysInRange)e=!0;else if(this.map){var t=this.map.getResolution();e=t>=this.minResolution&&t<=this.maxResolution}return e},setIsBaseLayer:function(e){e!=this.isBaseLayer&&(this.isBaseLayer=e,this.map!=null&&this.map.events.triggerEvent("changebaselayer",{layer:this}))},initResolutions:function(){var e,t,n,r={},i=!0;for(e=0,t=this.RESOLUTION_PROPERTIES.length;e<t;e++)n=this.RESOLUTION_PROPERTIES[e],r[n]=this.options[n],i&&this.options[n]&&(i=!1);this.options.alwaysInRange==null&&(this.alwaysInRange=i),r.resolutions==null&&(r.resolutions=this.resolutionsFromScales(r.scales)),r.resolutions==null&&(r.resolutions=this.calculateResolutions(r));if(r.resolutions==null){for(e=0,t=this.RESOLUTION_PROPERTIES.length;e<t;e++)n=this.RESOLUTION_PROPERTIES[e],r[n]=this.options[n]!=null?this.options[n]:this.map[n];r.resolutions==null&&(r.resolutions=this.resolutionsFromScales(r.scales)),r.resolutions==null&&(r.resolutions=this.calculateResolutions(r))}var s;this.options.maxResolution&&this.options.maxResolution!=="auto"&&(s=this.options.maxResolution),this.options.minScale&&(s=OpenLayers.Util.getResolutionFromScale(this.options.minScale,this.units));var o;this.options.minResolution&&this.options.minResolution!=="auto"&&(o=this.options.minResolution),this.options.maxScale&&(o=OpenLayers.Util.getResolutionFromScale(this.options.maxScale,this.units));if(r.resolutions){r.resolutions.sort(function(e,t){return t-e}),s||(s=r.resolutions[0]);if(!o){var u=r.resolutions.length-1;o=r.resolutions[u]}}this.resolutions=r.resolutions;if(this.resolutions){t=this.resolutions.length,this.scales=new Array(t);for(e=0;e<t;e++)this.scales[e]=OpenLayers.Util.getScaleFromResolution(this.resolutions[e],this.units);this.numZoomLevels=t}this.minResolution=o,o&&(this.maxScale=OpenLayers.Util.getScaleFromResolution(o,this.units)),this.maxResolution=s,s&&(this.minScale=OpenLayers.Util.getScaleFromResolution(s,this.units))},resolutionsFromScales:function(e){if(e==null)return;var t,n,r;r=e.length,t=new Array(r);for(n=0;n<r;n++)t[n]=OpenLayers.Util.getResolutionFromScale(e[n],this.units);return t},calculateResolutions:function(e){var t,n,r,i=e.maxResolution;e.minScale!=null?i=OpenLayers.Util.getResolutionFromScale(e.minScale,this.units):i=="auto"&&this.maxExtent!=null&&(t=this.map.getSize(),n=this.maxExtent.getWidth()/t.w,r=this.maxExtent.getHeight()/t.h,i=Math.max(n,r));var s=e.minResolution;e.maxScale!=null?s=OpenLayers.Util.getResolutionFromScale(e.maxScale,this.units):e.minResolution=="auto"&&this.minExtent!=null&&(t=this.map.getSize(),n=this.minExtent.getWidth()/t.w,r=this.minExtent.getHeight()/t.h,s=Math.max(n,r));if(typeof i!="number"&&typeof s!="number"&&this.maxExtent!=null){var o=this.map.getTileSize();i=Math.max(this.maxExtent.getWidth()/o.w,this.maxExtent.getHeight()/o.h)}var u=e.maxZoomLevel,a=e.numZoomLevels;if(typeof s=="number"&&typeof i=="number"&&a===undefined){var f=i/s;a=Math.floor(Math.log(f)/Math.log(2))+1}else a===undefined&&u!=null&&(a=u+1);if(typeof a!="number"||a<=0||typeof i!="number"&&typeof s!="number")return;var l=new Array(a),c=2;typeof s=="number"&&typeof i=="number"&&(c=Math.pow(i/s,1/(a-1)));var h;if(typeof i=="number")for(h=0;h<a;h++)l[h]=i/Math.pow(c,h);else for(h=0;h<a;h++)l[a-1-h]=s*Math.pow(c,h);return l},getResolution:function(){var e=this.map.getZoom();return this.getResolutionForZoom(e)},getExtent:function(){return this.map.calculateBounds()},getZoomForExtent:function(e,t){var n=this.map.getSize(),r=Math.max(e.getWidth()/n.w,e.getHeight()/n.h);return this.getZoomForResolution(r,t)},getDataExtent:function(){},getResolutionForZoom:function(e){e=Math.max(0,Math.min(e,this.resolutions.length-1));var t;if(this.map.fractionalZoom){var n=Math.floor(e),r=Math.ceil(e);t=this.resolutions[n]-(e-n)*(this.resolutions[n]-this.resolutions[r])}else t=this.resolutions[Math.round(e)];return t},getZoomForResolution:function(e,t){var n,r,i;if(this.map.fractionalZoom){var s=0,o=this.resolutions.length-1,u=this.resolutions[s],a=this.resolutions[o],f;for(r=0,i=this.resolutions.length;r<i;++r){f=this.resolutions[r],f>=e&&(u=f,s=r);if(f<=e){a=f,o=r;break}}var l=u-a;l>0?n=s+(u-e)/l:n=s}else{var c,h=Number.POSITIVE_INFINITY;for(r=0,i=this.resolutions.length;r<i;r++)if(t){c=Math.abs(this.resolutions[r]-e);if(c>h)break;h=c}else if(this.resolutions[r]<e)break;n=Math.max(0,r-1)}return n},getLonLatFromViewPortPx:function(e){var t=null,n=this.map;if(e!=null&&n.minPx){var r=n.getResolution(),i=n.getMaxExtent({restricted:!0}),s=(e.x-n.minPx.x)*r+i.left,o=(n.minPx.y-e.y)*r+i.top;t=new OpenLayers.LonLat(s,o),this.wrapDateLine&&(t=t.wrapDateLine(this.maxExtent))}return t},getViewPortPxFromLonLat:function(e,t){var n=null;if(e!=null){t=t||this.map.getResolution();var r=this.map.calculateBounds(null,t);n=new OpenLayers.Pixel(1/t*(e.lon-r.left),1/t*(r.top-e.lat))}return n},setOpacity:function(e){if(e!=this.opacity){this.opacity=e;var t=this.div.childNodes;for(var n=0,r=t.length;n<r;++n){var i=t[n].firstChild||t[n],s=t[n].lastChild;s&&s.nodeName.toLowerCase()==="iframe"&&(i=s.parentNode),OpenLayers.Util.modifyDOMElement(i,null,null,null,null,null,null,e)}this.map!=null&&this.map.events.triggerEvent("changelayer",{layer:this,property:"opacity"})}},getZIndex:function(){return this.div.style.zIndex},setZIndex:function(e){this.div.style.zIndex=e},adjustBounds:function(e){if(this.gutter){var t=this.gutter*this.map.getResolution();e=new OpenLayers.Bounds(e.left-t,e.bottom-t,e.right+t,e.top+t)}if(this.wrapDateLine){var n={rightTolerance:this.getResolution(),leftTolerance:this.getResolution()};e=e.wrapDateLine(this.maxExtent,n)}return e},CLASS_NAME:"OpenLayers.Layer"});