Merge all changes from the naturaldocs sandbox. This brings all the work that

has been done in the NaturalDocs branch back to trunk. Thanks to everyone who
helped out in making this happen. (I could list people, but the list would
be long, and I'm already mentally on vacation.)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@3545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-06-29 15:59:20 +00:00
parent f1c61fd0d6
commit 3948913bfc
107 changed files with 8658 additions and 4011 deletions
+282 -166
View File
@@ -4,155 +4,211 @@
/**
* @class
* @requires OpenLayers/Map.js
*
* Class: OpenLayers.Layer
*/
OpenLayers.Layer = OpenLayers.Class.create();
OpenLayers.Layer.prototype = {
/** @type String */
/**
* APIProperty: id
* {String}
*/
id: null,
/** @type String */
/**
* APIProperty: name
* {String}
*/
name: null,
/** @type DOMElement */
/**
* APIProperty: div
* {DOMElement}
*/
div: null,
/** supported application event types
*
* @type Array */
EVENT_TYPES: [
"loadstart", "loadend", "loadcancel"],
/** @type OpenLayers.Events */
/**
* Constant: EVENT_TYPES
* {Array(String)} Supported application event types
*/
EVENT_TYPES: [ "loadstart", "loadend", "loadcancel"],
/**
* APIProperty: events``
* {<OpenLayers.Events>}
*/
events: null,
/** This variable is set when the layer is added to the map, via the
* accessor function setMap()
*
* @type OpenLayers.Map */
/**
* APIProperty: map
* {<OpenLayers.Map>} This variable is set when the layer is added to
* the map, via the accessor function setMap().
*/
map: null,
/** Whether or not the layer is a base layer. This should be set
* individually by all subclasses.
* Default is false
*
* @type Boolean
/**
* APIProperty: isBaseLayer
* {Boolean} Whether or not the layer is a base layer. This should be set
* individually by all subclasses.
* Default is false
*/
isBaseLayer: false,
/** asserts whether or not the layer's images have an alpha channel
*
* @type boolean */
/**
* Property: alpha
* {Boolean} Whether or not the layer's images have an alpha channel
*/
alpha: false,
/** should the layer's name appear in the layer switcher?
*
* @type boolean */
/**
* APIProperty: displayInLayerSwitcher
* {Boolean} Should the layer's name appear in the layer switcher?
*/
displayInLayerSwitcher: true,
/** Whether or not the layer should be displayed in the map
*
* @type Boolean
/**
* APIProperty: visibility
* {Boolean} Whether or not the layer should be displayed in the map
*/
visibility: true,
/** Whether or not the map's current resolution is within this layer's
* min/max range -- this is set in map's setCenter() whenever zoom
* changes
*
* @type Boolean
/**
* APIProperty: inRange
* {Boolean} Whether or not the map's current resolution is within this
* layer's min/max range -- this is set in map's setCenter()
* whenever zoom changes.
*/
inRange: false,
/**
* For layers that use Tile.Image, the image size is cached here. For
* layers without a gutter, the image size is equal to the tile size.
* For layers with a gutter, the image is larger than the tile by twice
* the gutter in each dimension.
*
* @type OpenLayers.Size
* @private
* Propery: imageSize
* {<OpenLayers.Size>} For layers with a gutter, the image is larger than
* the tile by twice the gutter in each dimension.
*/
imageSize: null,
/**
* For layers that use Tile.Image, the image offset is cached here.
* Layers without a gutter have zero offset. For layers with a gutter,
* the image offset represents displacement due to the gutter.
*
* @type OpenLayers.Pixel
* @private
* Property: imageOffset
* {<OpenLayers.Pixel>} For layers with a gutter, the image offset
* represents displacement due to the gutter.
*/
imageOffset: null,
// OPTIONS
/** @type Array */
/**
* Property: options
* {Object}
*/
options: null,
/** Determines the width (in pixels) of the gutter around image tiles
* to ignore. By setting this property to a non-zero value, images
* will be requested that are wider and taller than the tile size by
* a value of 2 x gutter. This allows artifacts of rendering at tile
* edges to be ignored. Set a gutter value that is equal to half the size
* of the widest symbol that needs to be displayed. Defaults to zero.
* Non-tiled layers always have zero gutter.
*
* @type Int
*/
/**
* Property: gutter
* {Integer} Determines the width (in pixels) of the gutter around image
* tiles to ignore. By setting this property to a non-zero
* value, images will be requested that are wider and taller
* than the tile size by a value of 2 x gutter. This allows
* artifacts of rendering at tile edges to be ignored. Set a
* gutter value that is equal to half the size of the widest
* symbol that needs to be displayed. Defaults to zero.
* Non-tiled layers always have zero gutter.
*/
gutter: 0,
/** @type String */
/**
* Property: projection
* {String} Set in the layer options to override the default projection
* string this layer - also set maxExtent, maxResolution, and
* units if appropriate.
*/
projection: null,
/** @type String */
/**
* Property: units
* {String} The layer map units. Defaults to 'degrees'. Possible values
* are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'.
*/
units: null,
/** @type Array */
/**
* Property: scales
* {Array}
*/
scales: null,
/** @type Array */
/**
* Property: resolutions
* {Array}
*/
resolutions: null,
/** @type OpenLayers.Bounds */
/**
* Property: maxExtent
* {<OpenLayers.Bounds>}
*/
maxExtent: null,
/** @type OpenLayers.Bounds */
/**
* Property: minExtent
* {<OpenLayers.Bounds>}
*/
minExtent: null,
/** @type float */
/**
* Property: maxResolution
* {Float} Default max is 360 deg / 256 px, which corresponds to
* zoom level 0 on gmaps. Specify a different value in the layer
* options if you are not using a geographic projection and
* displaying the whole world.
*/
maxResolution: null,
/** @type float */
/**
* Property: minResolution
* {Float}
*/
minResolution: null,
/** @type int */
/**
* Property: numZoomLevels
* {Integer}
*/
numZoomLevels: null,
/** @type float */
/**
* Property: minScale
* {Float}
*/
minScale: null,
/** @type float */
/**
* Property: maxScale
* {Float}
*/
maxScale: null,
/** @type Boolean */
/**
* Property: displayOutsideMaxExtent
* {Boolean} Request map tiles that are completely outside of the max extent
* for this layer. Defaults to false
*/
displayOutsideMaxExtent: false,
/**
* wrapDateLine -- #487 for more info.
*
* @type Boolean
/**
* Property: wrapDateLine
* {Boolean} #487 for more info.
*/
wrapDateLine: false,
/**
* @constructor
*
* @param {String} name
* @param {Object} options Hashtable of extra options to tag onto the layer
* Constructor: OpenLayers.Layer
*
* Parameters:
* name - {String} The layer name
* options - {Object} Hashtable of extra options to tag onto the layer
*/
initialize: function(name, options) {
@@ -179,12 +235,14 @@ OpenLayers.Layer.prototype = {
},
/**
* Method: destroy
* Destroy is a destructor: this is to alleviate cyclic references which
* the Javascript garbage cleaner can not take care of on its own.
*
* @param {Boolean} setNewBaseLayer Should a new baselayer be selected when
* this has been removed?
* Default is true
* the Javascript garbage cleaner can not take care of on its own.
*
* Parameters:
* setNewBaseLayer - {Boolean} Should a new baselayer be selected when
* this has been removed?
* Default is true.
*/
destroy: function(setNewBaseLayer) {
if (setNewBaseLayer == null) {
@@ -205,8 +263,13 @@ OpenLayers.Layer.prototype = {
},
/**
* @returns An exact clone of this OpenLayers.Layer
* @type OpenLayers.Layer
* Method: clone
*
* Parameters:
* obj - {<OpenLayers.Layer>} The layer to be cloned
*
* Return:
* {<OpenLayers.Layer>} An exact clone of this <OpenLayers.Layer>
*/
clone: function (obj) {
@@ -225,7 +288,10 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {String} newName
* APIMethod: setName
*
* Parameters:
* newName - {String}
*/
setName: function(newName) {
if (newName != this.name) {
@@ -237,7 +303,10 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {Object} newOptions
* APIMethod: addOptions
*
* Parameters:
* newOptions - {Object}
*/
addOptions: function (newOptions) {
@@ -253,17 +322,21 @@ OpenLayers.Layer.prototype = {
},
/**
*
* APIMethod: onMapResize
* This function can be implemented by subclasses
*/
onMapResize: function() {
//this function can be implemented by subclasses
},
/**
* @param {OpenLayers.Bounds} bound
* @param {Boolean} zoomChanged tells when zoom has changed, as layers
* have to do some init work in that case.
* @param {Boolean} dragging
* Method: moveTo
*
* Parameters:
* bound - {<OpenLayers.Bounds>}
* zoomChanged - {Boolean} Tells when zoom has changed, as layers
* have to do some init work in that case.
* dragging - {Boolean}
*/
moveTo:function(bounds, zoomChanged, dragging) {
var display = this.visibility;
@@ -273,14 +346,17 @@ OpenLayers.Layer.prototype = {
this.display(display);
},
/** Set the map property for the layer. This is done through an accessor
* so that subclasses can override this and take special action once
* they have their map variable set.
/**
* Method: setMap
* Set the map property for the layer. This is done through an accessor
* so that subclasses can override this and take special action once
* they have their map variable set.
*
* Here we take care to bring over any of the necessary default properties
* from the map.
* Here we take care to bring over any of the necessary default properties
* from the map.
*
* @param {OpenLayers.Map} map
* Parameters:
* map - {<OpenLayers.Map>}
*/
setMap: function(map) {
if (this.map == null) {
@@ -307,10 +383,12 @@ OpenLayers.Layer.prototype = {
},
/**
* APIMethod: setTileSize
* Set the tile size based on the map size. This also sets layer.imageSize
* and layer.imageOffset for use by Tile.Image.
*
* @param {OpenLayers.Size}
* and layer.imageOffset for use by Tile.Image.
*
* Parameters:
* size - {<OpenLayers.Size>}
*/
setTileSize: function(size) {
var tileSize = (size) ? size :
@@ -336,25 +414,30 @@ OpenLayers.Layer.prototype = {
},
/**
* @returns Whether or not the layer should be displayed (if in range)
* @type Boolean
*/
* APIMethod: getVisibility
*
* Return:
* {Boolean} Whether or not the layer should be displayed (if in range)
*/
getVisibility: function() {
return this.visibility;
},
/** Set the visibility flag for the layer and hide/show&redraw accordingly.
* Fire event unless otherwise specified
/**
* APIMethod: setVisibility
* Set the visibility flag for the layer and hide/show&redraw accordingly.
* Fire event unless otherwise specified
*
* Note that visibility is no longer simply whether or not the layer's
* style.display is set to "block". Now we store a 'visibility' state
* property on the layer class, this allows us to remember whether or not
* we *desire* for a layer to be visible. In the case where the map's
* resolution is out of the layer's range, this desire may be subverted.
*
* @param {Boolean} visible Whether or not to display the layer
* (if in range)
* @param {Boolean} noEvent
* Note that visibility is no longer simply whether or not the layer's
* style.display is set to "block". Now we store a 'visibility' state
* property on the layer class, this allows us to remember whether or
* not we *desire* for a layer to be visible. In the case where the
* map's resolution is out of the layer's range, this desire may be
* subverted.
*
* Parameters:
* visible - {Boolean} Whether or not to display the layer (if in range)
* noEvent - {Boolean}
*/
setVisibility: function(visibility, noEvent) {
if (visibility != this.visibility) {
@@ -373,9 +456,12 @@ OpenLayers.Layer.prototype = {
}
},
/** Hide or show the Layer
/**
* APIMethod: display
* Hide or show the Layer
*
* @param {Boolean} display
* Parameters:
* display - {Boolean}
*/
display: function(display) {
if (display != (this.div.style.display != "none")) {
@@ -384,9 +470,11 @@ OpenLayers.Layer.prototype = {
},
/**
* @returns Whether or not the layer is displayable at the current map's
* current resolution
* @type Boolean
* Method: calculateInRange
*
* Return:
* {Boolean} Whether or not the layer is displayable at the current map's
* current resolution
*/
calculateInRange: function() {
var inRange = false;
@@ -399,7 +487,10 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {Boolean} isBaseLayer
* APIMethod: setIsBaseLayer
*
* Parameters:
* isBaseLayer - {Boolean}
*/
setIsBaseLayer: function(isBaseLayer) {
if (isBaseLayer != this.isBaseLayer) {
@@ -416,19 +507,19 @@ OpenLayers.Layer.prototype = {
/* */
/********************************************************/
/** This method's responsibility is to set up the 'resolutions' array
* for the layer -- this array is what the layer will use to interface
* between the zoom levels of the map and the resolution display of the
* layer.
/**
* Method: initResolutions
* This method's responsibility is to set up the 'resolutions' array
* for the layer -- this array is what the layer will use to interface
* between the zoom levels of the map and the resolution display
* of the layer.
*
* The user has several options that determine how the array is set up.
* The user has several options that determine how the array is set up.
*
* For a detailed explanation, see the following wiki from the
* openlayers.org homepage:
* For a detailed explanation, see the following wiki from the
* openlayers.org homepage:
*
* http://trac.openlayers.org/wiki/SettingZoomLevels
*
* @private
* http://trac.openlayers.org/wiki/SettingZoomLevels
*/
initResolutions: function() {
@@ -550,9 +641,11 @@ OpenLayers.Layer.prototype = {
},
/**
* @returns The currently selected resolution of the map, taken from the
* resolutions array, indexed by current zoom level.
* @type float
* APIMethod: getResolution
*
* Return:
* {Float} The currently selected resolution of the map, taken from the
* resolutions array, indexed by current zoom level.
*/
getResolution: function() {
var zoom = this.map.getZoom();
@@ -560,9 +653,11 @@ OpenLayers.Layer.prototype = {
},
/**
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
* APIMethod: getExtent
*
* Return:
* {<OpenLayers.Bounds>} A Bounds object which represents the lon/lat
* bounds of the current viewPort.
*/
getExtent: function() {
// just use stock map calculateBounds function -- passing no arguments
@@ -572,14 +667,17 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {OpenLayers.Bounds} bounds
* APIMethod: getZoomForExtent
*
* Parameters:
* bounds - {<OpenLayers.Bounds>}
*
* @returns The index of the zoomLevel (entry in the resolutions array)
* Return:
* {Integer} The index of the zoomLevel (entry in the resolutions array)
* that still contains the passed-in extent. We do this by
* calculating the ideal resolution for the given exteng (based
* on the map size) and then find the smallest resolution that
* is greater than this ideal resolution.
* @type int
*/
getZoomForExtent: function(extent) {
var viewSize = this.map.getSize();
@@ -590,12 +688,15 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {float} resolution
*
* @returns The index of the zoomLevel (entry in the resolutions array)
* APIMethod: getZoomForResolution
*
* Parameters:
* resolution - {Float}
*
* Return:
* {Integer} The index of the zoomLevel (entry in the resolutions array)
* that is the smallest resolution that is greater than the
* passed-in resolution.
* @type int
*/
getZoomForResolution: function(resolution) {
@@ -608,11 +709,15 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {OpenLayers.Pixel} viewPortPx
* APIMethod: getLonLatFromViewPortPx
*
* Parameters:
* viewPortPx - {<OpenLayers.Pixel>}
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by the layer
* @type OpenLayers.LonLat
* Return:
* {<OpenLayers.LonLat>} An OpenLayers.LonLat which is the passed-in
* view port <OpenLayers.Pixel>, translated into
* lon/lat by the layer
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null;
@@ -637,11 +742,15 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {OpenLayers.LonLat} lonlat
* APIMethod: getViewPortPxFromLonLat
*
* Parameters:
* lonlat - {<OpenLayers.LonLat>}
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels
* @type OpenLayers.Pixel
* Return:
* {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in
* <OpenLayers.LonLat>,translated into view
* port pixels.
*/
getViewPortPxFromLonLat: function (lonlat) {
var px = null;
@@ -657,8 +766,11 @@ OpenLayers.Layer.prototype = {
},
/**
* APIMethod: setOpacity
* Sets the opacity for the entire layer (all images)
* @param {Float} opacity
*
* Parameter:
* opacity - {Float}
*/
setOpacity: function(opacity) {
if (opacity != this.opacity) {
@@ -672,22 +784,26 @@ OpenLayers.Layer.prototype = {
},
/**
* @param {int} zIdx
* @private
*/
setZIndex: function (zIdx) {
this.div.style.zIndex = zIdx;
* Method: setZIndex
*
* Parameters:
* zIndex - {Integer}
*/
setZIndex: function (zIndex) {
this.div.style.zIndex = zIndex;
},
/**
* This function will take a bounds, and if wrapDateLine option is set
* on the layer, it will return a bounds which is wrapped around the world.
* We do not wrap for bounds which *cross* the maxExtent.left/right, only
* bounds which are entirely to the left or entirely to the right.
*
* @param {OpenLayers.Bounds} bounds
* @private
*/
* Method: adjustBounds
* This function will take a bounds, and if wrapDateLine option is set
* on the layer, it will return a bounds which is wrapped around the
* world. We do not wrap for bounds which *cross* the
* maxExtent.left/right, only bounds which are entirely to the left
* or entirely to the right.
*
* Parameters:
* bounds - {<OpenLayers.Bounds>}
*/
adjustBounds: function (bounds) {
if (this.gutter) {