coding standards and a few improved doc comments

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3836 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-01 23:06:58 +00:00
parent 323a62e926
commit c733d7bcff
+63 -61
View File
@@ -43,55 +43,54 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* APIProperty: map * APIProperty: map
* {<OpenLayers.Map>} This variable is set when the layer is added to * {<OpenLayers.Map>} This variable is set when the layer is added to
* the map, via the accessor function setMap(). * the map, via the accessor function setMap().
*/ */
map: null, map: null,
/** /**
* APIProperty: isBaseLayer * APIProperty: isBaseLayer
* {Boolean} Whether or not the layer is a base layer. This should be set * {Boolean} Whether or not the layer is a base layer. This should be set
* individually by all subclasses. * individually by all subclasses. Default is false
* Default is false
*/ */
isBaseLayer: false, isBaseLayer: false,
/** /**
* Property: alpha * Property: alpha
* {Boolean} Whether or not the layer's images have an alpha channel * {Boolean} The layer's images have an alpha channel. Default is false.
*/ */
alpha: false, alpha: false,
/** /**
* APIProperty: displayInLayerSwitcher * APIProperty: displayInLayerSwitcher
* {Boolean} Should the layer's name appear in the layer switcher? * {Boolean} Display the layer's name in the layer switcher. Default is
* true.
*/ */
displayInLayerSwitcher: true, displayInLayerSwitcher: true,
/** /**
* APIProperty: visibility * APIProperty: visibility
* {Boolean} Whether or not the layer should be displayed in the map * {Boolean} The layer should be displayed in the map. Default is true.
*/ */
visibility: true, visibility: true,
/** /**
* APIProperty: inRange * Property: inRange
* {Boolean} Whether or not the map's current resolution is within this * {Boolean} The current map resolution is within the layer's min/max range.
* layer's min/max range -- this is set in map's setCenter() * This is set in <OpenLayers.Map.setCenter> whenever the zoom changes.
* whenever zoom changes.
*/ */
inRange: false, inRange: false,
/** /**
* Propery: imageSize * Propery: imageSize
* {<OpenLayers.Size>} For layers with a gutter, the image is larger than * {<OpenLayers.Size>} For layers with a gutter, the image is larger than
* the tile by twice the gutter in each dimension. * the tile by twice the gutter in each dimension.
*/ */
imageSize: null, imageSize: null,
/** /**
* Property: imageOffset * Property: imageOffset
* {<OpenLayers.Pixel>} For layers with a gutter, the image offset * {<OpenLayers.Pixel>} For layers with a gutter, the image offset
* represents displacement due to the gutter. * represents displacement due to the gutter.
*/ */
imageOffset: null, imageOffset: null,
@@ -100,57 +99,64 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* Property: options * Property: options
* {Object} An optional object whose properties will be set on the layer. * {Object} An optional object whose properties will be set on the layer.
* Any of the layer properties can be set as a property of the options * Any of the layer properties can be set as a property of the options
* object and sent to the constructor when the layer is created. * object and sent to the constructor when the layer is created.
*/ */
options: null, options: null,
/** /**
* APIProperty: gutter * APIProperty: gutter
* {Integer} Determines the width (in pixels) of the gutter around image * {Integer} Determines the width (in pixels) of the gutter around image
* tiles to ignore. By setting this property to a non-zero * tiles to ignore. By setting this property to a non-zero value,
* value, images will be requested that are wider and taller * images will be requested that are wider and taller than the tile
* than the tile size by a value of 2 x gutter. This allows * size by a value of 2 x gutter. This allows artifacts of rendering
* artifacts of rendering at tile edges to be ignored. Set a * at tile edges to be ignored. Set a gutter value that is equal to
* gutter value that is equal to half the size of the widest * half the size of the widest symbol that needs to be displayed.
* symbol that needs to be displayed. Defaults to zero. * Defaults to zero. Non-tiled layers always have zero gutter.
* Non-tiled layers always have zero gutter.
*/ */
gutter: 0, gutter: 0,
/** /**
* APIProperty: projection * APIProperty: projection
* {String} Set in the layer options to override the default projection * {String} Set in the layer options to override the default projection
* string this layer - also set maxExtent, maxResolution, and * string this layer - also set maxExtent, maxResolution, and units if
* units if appropriate. * appropriate.
*/ */
projection: null, projection: null,
/** /**
* APIProperty: units * APIProperty: units
* {String} The layer map units. Defaults to 'degrees'. Possible values * {String} The layer map units. Defaults to 'degrees'. Possible values
* are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'. * are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'.
*/ */
units: null, units: null,
/** /**
* APIProperty: scales * APIProperty: scales
* {Array} * {Array} An array of map scales in descending order. The values in the
* array correspond to the map scale denominator. Note that these
* values only make sense if the display (monitor) resolution of the
* client is correctly guessed by whomever is configuring the
* application. In addition, the units property must also be set.
* Use <resolutions> instead wherever possible.
*/ */
scales: null, scales: null,
/** /**
* APIProperty: resolutions * APIProperty: resolutions
* {Array} A list of map resolutions (map units per pixel) in descending * {Array} A list of map resolutions (map units per pixel) in descending
* order. If this is not set in the layer constructor, it will be set * order. If this is not set in the layer constructor, it will be set
* based on other resolution related properties (maxExtent, maxResolution, * based on other resolution related properties (maxExtent,
* maxScale, etc.). * maxResolution, maxScale, etc.).
*/ */
resolutions: null, resolutions: null,
/** /**
* APIProperty: maxExtent * APIProperty: maxExtent
* {<OpenLayers.Bounds>} * {<OpenLayers.Bounds>} The center of these bounds will not stray outside
* of the viewport extent during panning. In addition, if
* <displayOutsideMaxExtent> is set to false, data will not be
* requested that falls completely outside of these bounds.
*/ */
maxExtent: null, maxExtent: null,
@@ -163,9 +169,9 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* APIProperty: maxResolution * APIProperty: maxResolution
* {Float} Default max is 360 deg / 256 px, which corresponds to * {Float} Default max is 360 deg / 256 px, which corresponds to
* zoom level 0 on gmaps. Specify a different value in the layer * zoom level 0 on gmaps. Specify a different value in the layer
* options if you are not using a geographic projection and * options if you are not using a geographic projection and
* displaying the whole world. * displaying the whole world.
*/ */
maxResolution: null, maxResolution: null,
@@ -196,7 +202,7 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* APIProperty: displayOutsideMaxExtent * APIProperty: displayOutsideMaxExtent
* {Boolean} Request map tiles that are completely outside of the max extent * {Boolean} Request map tiles that are completely outside of the max extent
* for this layer. Defaults to false * for this layer. Defaults to false.
*/ */
displayOutsideMaxExtent: false, displayOutsideMaxExtent: false,
@@ -244,9 +250,8 @@ OpenLayers.Layer = OpenLayers.Class({
* the Javascript garbage cleaner can not take care of on its own. * the Javascript garbage cleaner can not take care of on its own.
* *
* Parameters: * Parameters:
* setNewBaseLayer - {Boolean} Should a new baselayer be selected when * setNewBaseLayer - {Boolean} Set a new base layer when this layer has
* this has been removed? * been destroyed. Default is true.
* Default is true.
*/ */
destroy: function(setNewBaseLayer) { destroy: function(setNewBaseLayer) {
if (setNewBaseLayer == null) { if (setNewBaseLayer == null) {
@@ -293,8 +298,8 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* APIMethod: setName * APIMethod: setName
* Sets the new layer name for this layer. Can trigger * Sets the new layer name for this layer. Can trigger a changelayer event
* a changelayer event on the map. * on the map.
* *
* Parameters: * Parameters:
* newName - {String} The new name. * newName - {String} The new name.
@@ -365,8 +370,8 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Parameters: * Parameters:
* bound - {<OpenLayers.Bounds>} * bound - {<OpenLayers.Bounds>}
* zoomChanged - {Boolean} Tells when zoom has changed, as layers * zoomChanged - {Boolean} Tells when zoom has changed, as layers have to
* have to do some init work in that case. * do some init work in that case.
* dragging - {Boolean} * dragging - {Boolean}
*/ */
moveTo:function(bounds, zoomChanged, dragging) { moveTo:function(bounds, zoomChanged, dragging) {
@@ -418,7 +423,7 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {<OpenLayers.Size>} The size that the image should be, taking into * {<OpenLayers.Size>} The size that the image should be, taking into
* account gutters. * account gutters.
*/ */
getImageSize: function() { getImageSize: function() {
return (this.imageSize || this.tileSize); return (this.imageSize || this.tileSize);
@@ -454,7 +459,7 @@ OpenLayers.Layer = OpenLayers.Class({
* APIMethod: getVisibility * APIMethod: getVisibility
* *
* Return: * Return:
* {Boolean} Whether or not the layer should be displayed (if in range) * {Boolean} The layer should be displayed (if in range).
*/ */
getVisibility: function() { getVisibility: function() {
return this.visibility; return this.visibility;
@@ -462,10 +467,10 @@ OpenLayers.Layer = OpenLayers.Class({
/** /**
* APIMethod: setVisibility * APIMethod: setVisibility
* Set the visibility flag for the layer and hide/show&redraw accordingly. * Set the visibility flag for the layer and hide/show & redraw accordingly.
* Fire event unless otherwise specified * Fire event unless otherwise specified
* *
* Note that visibility is no longer simply whether or not the layer's * 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 * style.display is set to "block". Now we store a 'visibility' state
* property on the layer class, this allows us to remember whether or * 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 * not we *desire* for a layer to be visible. In the case where the
@@ -505,8 +510,8 @@ OpenLayers.Layer = OpenLayers.Class({
* Method: calculateInRange * Method: calculateInRange
* *
* Return: * Return:
* {Boolean} Whether or not the layer is displayable at the current map's * {Boolean} The layer is displayable at the current map's current
* current resolution * resolution.
*/ */
calculateInRange: function() { calculateInRange: function() {
var inRange = false; var inRange = false;
@@ -546,11 +551,10 @@ OpenLayers.Layer = OpenLayers.Class({
* between the zoom levels of the map and the resolution display * between the zoom levels of the map and the resolution display
* of the layer. * 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 * For a detailed explanation, see the following wiki from the
* openlayers.org homepage: * openlayers.org homepage:
*
* http://trac.openlayers.org/wiki/SettingZoomLevels * http://trac.openlayers.org/wiki/SettingZoomLevels
*/ */
initResolutions: function() { initResolutions: function() {
@@ -677,7 +681,7 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {Float} The currently selected resolution of the map, taken from the * {Float} The currently selected resolution of the map, taken from the
* resolutions array, indexed by current zoom level. * resolutions array, indexed by current zoom level.
*/ */
getResolution: function() { getResolution: function() {
var zoom = this.map.getZoom(); var zoom = this.map.getZoom();
@@ -689,7 +693,7 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {<OpenLayers.Bounds>} A Bounds object which represents the lon/lat * {<OpenLayers.Bounds>} A Bounds object which represents the lon/lat
* bounds of the current viewPort. * bounds of the current viewPort.
*/ */
getExtent: function() { getExtent: function() {
// just use stock map calculateBounds function -- passing no arguments // just use stock map calculateBounds function -- passing no arguments
@@ -706,10 +710,10 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {Integer} The index of the zoomLevel (entry in the resolutions array) * {Integer} The index of the zoomLevel (entry in the resolutions array)
* that still contains the passed-in extent. We do this by * that still contains the passed-in extent. We do this by calculating
* calculating the ideal resolution for the given exteng (based * the ideal resolution for the given exteng (based on the map size)
* on the map size) and then find the smallest resolution that * and then find the smallest resolution that is greater than this
* is greater than this ideal resolution. * ideal resolution.
*/ */
getZoomForExtent: function(extent) { getZoomForExtent: function(extent) {
var viewSize = this.map.getSize(); var viewSize = this.map.getSize();
@@ -727,8 +731,8 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {Integer} The index of the zoomLevel (entry in the resolutions array) * {Integer} The index of the zoomLevel (entry in the resolutions array)
* that is the smallest resolution that is greater than the * that is the smallest resolution that is greater than the passed-in
* passed-in resolution. * resolution.
*/ */
getZoomForResolution: function(resolution) { getZoomForResolution: function(resolution) {
@@ -748,8 +752,7 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {<OpenLayers.LonLat>} An OpenLayers.LonLat which is the passed-in * {<OpenLayers.LonLat>} An OpenLayers.LonLat which is the passed-in
* view port <OpenLayers.Pixel>, translated into * view port <OpenLayers.Pixel>, translated into lon/lat by the layer.
* lon/lat by the layer
*/ */
getLonLatFromViewPortPx: function (viewPortPx) { getLonLatFromViewPortPx: function (viewPortPx) {
var lonlat = null; var lonlat = null;
@@ -781,8 +784,7 @@ OpenLayers.Layer = OpenLayers.Class({
* *
* Return: * Return:
* {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in * {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in
* <OpenLayers.LonLat>,translated into view * <OpenLayers.LonLat>,translated into view port pixels.
* port pixels.
*/ */
getViewPortPxFromLonLat: function (lonlat) { getViewPortPxFromLonLat: function (lonlat) {
var px = null; var px = null;