From b655b14f01a45841844ac8cdab0552cb9031d094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 9 Dec 2009 11:51:55 +0000 Subject: [PATCH] NavigationHistory - move the code for getting the current state from an anonymous function to a method of the class, r=bartvde (closes #2377) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9867 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/NavigationHistory.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Control/NavigationHistory.js b/lib/OpenLayers/Control/NavigationHistory.js index baed374f47..a70df16747 100644 --- a/lib/OpenLayers/Control/NavigationHistory.js +++ b/lib/OpenLayers/Control/NavigationHistory.js @@ -126,12 +126,7 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { OpenLayers.Control.prototype.initialize.apply(this, [options]); this.registry = OpenLayers.Util.extend({ - "moveend": function() { - return { - center: this.map.getCenter(), - resolution: this.map.getResolution() - }; - } + "moveend": this.getState }, this.registry); this.clear(); @@ -288,6 +283,20 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, { this.nextStack = []; }, + /** + * Method: getState + * Get the current state and return it. + * + * Returns: + * {Object} An object representing the current state. + */ + getState: function() { + return { + center: this.map.getCenter(), + resolution: this.map.getResolution() + }; + }, + /** * Method: restore * Update the state with the given object.