Hi!

Enclosed a small patch to optionally also track base layer changes in the
NavigationHistory Control. Just set the trackBaseLayerChange option to true.
Default is false, ie. old behaviour.

I use this at http://bestofosm.org/ .

Jochen
-- 
Jochen Topf  joc...@remote.org  http://www.remote.org/jochen/  +49-721-388298
--- work/openlayers/trunk/openlayers/lib/OpenLayers/Control/NavigationHistory.js	2009-07-27 21:19:44.000000000 +0200
+++ NavigationHistory.js	2009-08-15 10:34:50.000000000 +0200
@@ -67,6 +67,12 @@
     limit: 50,
 
     /**
+     * APIProperty: trackBaseLayerChange
+     * {Boolean} Track changes of base layer in history items. Default is false.
+     */
+    trackBaseLayerChange: false,
+
+    /**
      * APIProperty: autoActivate
      * {Boolean} Activate the control when it is added to a map.  Default is
      *     true.
@@ -127,10 +133,14 @@
         
         this.registry = OpenLayers.Util.extend({
             "moveend": function() {
-                return {
+                var state = {
                     center: this.map.getCenter(),
-                    resolution: this.map.getResolution()                
+                    resolution: this.map.getResolution()
                 };
+                if (this.trackBaseLayerChange) {
+                    state.baselayer = this.map.baseLayer;
+                }
+                return state;
             }
         }, this.registry);
         
@@ -296,6 +306,9 @@
      * state - {Object} An object representing the state to restore.
      */
     restore: function(state) {
+        if (state.baselayer) {
+            this.map.setBaseLayer(state.baselayer);
+        }
         var zoom = this.map.getZoomForResolution(state.resolution);
         this.map.setCenter(state.center, zoom);
     },
_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev

Reply via email to