refactor range checking into map and store a state variable in layer so that we dont fire changelayer every time user zooms

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1606 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-10-05 19:32:07 +00:00
parent 3cf66a5779
commit 2b7c6cc844
3 changed files with 20 additions and 8 deletions
+10 -5
View File
@@ -47,6 +47,14 @@ OpenLayers.Layer.prototype = {
*/
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
*/
inRange: false,
// OPTIONS
/** @type Array */
@@ -186,10 +194,7 @@ OpenLayers.Layer.prototype = {
* @param {Boolean} dragging
*/
moveTo:function(bounds, zoomChanged, dragging) {
if (zoomChanged) {
this.display(this.visibility && this.inRange());
this.map.events.triggerEvent("changelayer");
}
this.display(this.visibility && this.inRange);
},
/** Set the map property for the layer. This is done through an accessor
@@ -266,7 +271,7 @@ OpenLayers.Layer.prototype = {
* current resolution
* @type Boolean
*/
inRange: function() {
calculateInRange: function() {
var inRange = false;
if (this.map) {
var resolution = this.map.getResolution();