Files
openlayers/lib/OpenLayers/Layer.js
crschmidt 1d1452da61 r439@creusa: crschmidt | 2006-05-29 13:32:54 -0400
Change Layer.js to call a moveTo function after visibility changes: This allows us to implement #56. Layer/Grid.js now has code which shows how to have a layer which doesn't load when it's not visible: This code will be dependant on the layers, so this has to be implemented per class. However, classes like markers suffer very little performance cost for drawing, so Layer.Grid is the most important place for this improvement.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@458 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2006-05-29 19:18:29 +00:00

67 lines
1.5 KiB
JavaScript

OpenLayers.Layer = Class.create();
OpenLayers.Layer.prototype = {
// str
name: null,
// DOMElement
div: null,
/** This variable is set in map.addLayer, not within the layer itself
* @type OpenLayers.Map */
map: null,
// str -- projection for use in WFS, WMS, etc.
projection: null,
/**
* @param {str} name
*/
initialize: function(name) {
if (arguments.length > 0) {
this.name = name;
if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
this.div.style.width = "100%";
this.div.style.height = "100%";
}
}
},
/**
* Destroy is a destructor: this is to alleviate cyclic references which
* the Javascript garbage cleaner can not take care of on its own.
*/
destroy: function() {
this.map = null;
},
/**
* @params {OpenLayers.Bounds} bound
* @params {bool} zoomChanged tells when zoom has changed, as layers have to do some init work in that case.
*/
moveTo: function (bound,zoomChanged) {
// not implemented here
return;
},
/**
* @return {bool}
*/
getVisibility: function() {
return (this.div.style.display != "none");
},
/**
* @param {bool} visible
*/
setVisibility: function(visible) {
this.div.style.display = (visible) ? "block" : "none";
this.moveTo(this.map.getExtent());
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer"
};