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:
@@ -3,59 +3,93 @@
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @requires OpenLayers/Control.js
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control.js
|
||||
* Class: OpenLayers.Control.LayerSwitcher
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create();
|
||||
OpenLayers.Control.LayerSwitcher.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
|
||||
/** @type String */
|
||||
/**
|
||||
* Property: activeColor
|
||||
*/
|
||||
activeColor: "darkblue",
|
||||
|
||||
|
||||
// DOM Elements
|
||||
|
||||
/** @type DOMElement */
|
||||
/**
|
||||
* Property: layersDiv
|
||||
* {DOMElement}
|
||||
*/
|
||||
layersDiv: null,
|
||||
|
||||
/** @type DOMElement */
|
||||
/**
|
||||
* Property: baseLayersDiv
|
||||
* {DOMElement}
|
||||
*/
|
||||
baseLayersDiv: null,
|
||||
|
||||
/** @type Array */
|
||||
/**
|
||||
* Property: baseLayers
|
||||
* {Array}
|
||||
*/
|
||||
baseLayers: null,
|
||||
|
||||
|
||||
/** @type DOMElement */
|
||||
/**
|
||||
* Property: dataLbl
|
||||
* {DOMElement}
|
||||
*/
|
||||
dataLbl: null,
|
||||
|
||||
/** @type DOMElement */
|
||||
/**
|
||||
* Property: dataLayersDiv
|
||||
* {DOMElement}
|
||||
*/
|
||||
dataLayersDiv: null,
|
||||
|
||||
/** @type Array */
|
||||
/**
|
||||
* Property: dataLayers
|
||||
* {Array}
|
||||
*/
|
||||
dataLayers: null,
|
||||
|
||||
|
||||
/** @type DOMElement */
|
||||
/**
|
||||
* Property: minimizeDiv
|
||||
* {DOMElement}
|
||||
*/
|
||||
minimizeDiv: null,
|
||||
|
||||
/** @type DOMElement */
|
||||
/**
|
||||
* Property: maximizeDiv
|
||||
* {DOMElement}
|
||||
*/
|
||||
maximizeDiv: null,
|
||||
|
||||
/** @type Boolean */
|
||||
/**
|
||||
* APIProperty: ascending
|
||||
* {Boolean}
|
||||
*/
|
||||
ascending: true,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
* Constructor: OpenLayers.Control.LayerSwitcher
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
@@ -77,7 +111,10 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
* Method: setMap
|
||||
*
|
||||
* Properties:
|
||||
* map - {<OpenLayers.Map>}
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
@@ -89,8 +126,11 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
||||
* @type DOMElement
|
||||
* Method: draw
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} A reference to the DIV DOMElement containing the switcher
|
||||
* tabs
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this);
|
||||
@@ -109,12 +149,13 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/** user specifies either "base" or "data". we then clear all the
|
||||
* corresponding listeners, the div, and reinitialize a new array.
|
||||
/**
|
||||
* Method: clearLayersArray
|
||||
* user specifies either "base" or "data". we then clear all the
|
||||
* corresponding listeners, the div, and reinitialize a new array.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {String} layersType Ei
|
||||
* Parameters:
|
||||
* layersType - {String}
|
||||
*/
|
||||
clearLayersArray: function(layersType) {
|
||||
var layers = this[layersType + "Layers"];
|
||||
@@ -130,12 +171,14 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
},
|
||||
|
||||
|
||||
/** Goes through and takes the current state of the Map and rebuilds the
|
||||
* control to display that state. Groups base layers into a radio-button
|
||||
* group and lists each data layer with a checkbox.
|
||||
*
|
||||
* @returns A reference to the DIV DOMElement containing the control
|
||||
* @type DOMElement
|
||||
/**
|
||||
* Method: redraw
|
||||
* Goes through and takes the current state of the Map and rebuilds the
|
||||
* control to display that state. Groups base layers into a radio-button
|
||||
* group and lists each data layer with a checkbox.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} A reference to the DIV DOMElement containing the control
|
||||
*/
|
||||
redraw: function() {
|
||||
|
||||
@@ -219,16 +262,17 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/** A label has been clicked, check or uncheck its corresponding input
|
||||
/**
|
||||
* Method:
|
||||
* A label has been clicked, check or uncheck its corresponding input
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @context
|
||||
* {DOMElement} inputElem
|
||||
* {OpenLayers.Control.LayerSwitcher} layerSwitcher
|
||||
* {OpenLayers.Layer} layer
|
||||
*
|
||||
* @param {Event} e
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*
|
||||
* Context:
|
||||
* - {DOMElement} inputElem
|
||||
* - {<OpenLayers.Control.LayerSwitcher>} layerSwitcher
|
||||
* - {<OpenLayers.Layer>} layer
|
||||
*/
|
||||
|
||||
onInputClick: function(e) {
|
||||
@@ -246,23 +290,24 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
OpenLayers.Event.stop(e);
|
||||
},
|
||||
|
||||
/** Need to update the map accordingly whenever user clicks in either of
|
||||
* the layers.
|
||||
/**
|
||||
* Method:
|
||||
* Need to update the map accordingly whenever user clicks in either of
|
||||
* the layers.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Event} e
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*/
|
||||
onLayerClick: function(e) {
|
||||
this.updateMap();
|
||||
},
|
||||
|
||||
|
||||
/** Cycles through the loaded data and base layer input arrays and makes
|
||||
/**
|
||||
* Method: updateMap
|
||||
* Cycles through the loaded data and base layer input arrays and makes
|
||||
* the necessary calls to the Map object such that that the map's
|
||||
* visual state corresponds to what the user has selected in the control
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
updateMap: function() {
|
||||
|
||||
@@ -282,9 +327,12 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
},
|
||||
|
||||
/** Set up the labels and divs for the control
|
||||
/**
|
||||
* Method: maximizeControl
|
||||
* Set up the labels and divs for the control
|
||||
*
|
||||
* @param {Event} e
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*/
|
||||
maximizeControl: function(e) {
|
||||
|
||||
@@ -299,10 +347,13 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/** Hide all the contents of the control, shrink the size,
|
||||
* add the maximize icon
|
||||
*
|
||||
* @param {Event} e
|
||||
/**
|
||||
* Method: minimizeControl
|
||||
* Hide all the contents of the control, shrink the size,
|
||||
* add the maximize icon
|
||||
*
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*/
|
||||
minimizeControl: function(e) {
|
||||
|
||||
@@ -316,12 +367,13 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/** Hide/Show all LayerSwitcher controls depending on whether we are
|
||||
/**
|
||||
* Method: showControls
|
||||
* Hide/Show all LayerSwitcher controls depending on whether we are
|
||||
* minimized or not
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Boolean} minimize
|
||||
* Parameters:
|
||||
* minimize - {Boolean}
|
||||
*/
|
||||
showControls: function(minimize) {
|
||||
|
||||
@@ -331,8 +383,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
this.layersDiv.style.display = minimize ? "none" : "";
|
||||
},
|
||||
|
||||
/** Set up the labels and divs for the control
|
||||
*
|
||||
/**
|
||||
* Method: loadContents
|
||||
* Set up the labels and divs for the control
|
||||
*/
|
||||
loadContents: function() {
|
||||
|
||||
@@ -460,33 +513,36 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {Event} evt
|
||||
* Method: ignoreEvent
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
ignoreEvent: function(evt) {
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/** Register a local 'mouseDown' flag so that we'll know whether or not
|
||||
/**
|
||||
* Method: mouseDown
|
||||
* Register a local 'mouseDown' flag so that we'll know whether or not
|
||||
* to ignore a mouseUp event
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Event} evt
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
mouseDown: function(evt) {
|
||||
this.mouseDown = true;
|
||||
this.ignoreEvent(evt);
|
||||
},
|
||||
|
||||
/** If the 'mouseDown' flag has been set, that means that the drag was
|
||||
/**
|
||||
* Method: mouseUp
|
||||
* If the 'mouseDown' flag has been set, that means that the drag was
|
||||
* started from within the LayerSwitcher control, and thus we can
|
||||
* ignore the mouseup. Otherwise, let the Event continue.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Event} evt
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
mouseUp: function(evt) {
|
||||
if (this.mouseDown) {
|
||||
|
||||
Reference in New Issue
Block a user