[OpenLayers-Commits] r12121 - in trunk/openlayers: lib/OpenLayers lib/OpenLayers/Handler lib/OpenLayers/Layer tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Jun 22 02:04:11 EDT 2011


Author: ahocevar
Date: 2011-06-21 23:04:10 -0700 (Tue, 21 Jun 2011)
New Revision: 12121

Modified:
   trunk/openlayers/lib/OpenLayers/Handler/Feature.js
   trunk/openlayers/lib/OpenLayers/Layer/Bing.js
   trunk/openlayers/lib/OpenLayers/Layer/GoogleNG.js
   trunk/openlayers/lib/OpenLayers/Map.js
   trunk/openlayers/tests/Handler/Feature.html
Log:
don't fire changelayer events without a property, and do a more solid changelayer event check before changing the layer zIndex. r=tschaub (closes #3377)

Modified: trunk/openlayers/lib/OpenLayers/Handler/Feature.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Handler/Feature.js	2011-06-21 20:53:53 UTC (rev 12120)
+++ trunk/openlayers/lib/OpenLayers/Handler/Feature.js	2011-06-22 06:04:10 UTC (rev 12121)
@@ -404,7 +404,7 @@
      * evt - {Object}
      */
     handleMapEvents: function(evt) {
-        if (!evt.property || evt.property == "order") {
+        if (evt.type == "removelayer" || evt.property == "order") {
             this.moveLayerToTop();
         }
     },

Modified: trunk/openlayers/lib/OpenLayers/Layer/Bing.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Bing.js	2011-06-21 20:53:53 UTC (rev 12120)
+++ trunk/openlayers/lib/OpenLayers/Layer/Bing.js	2011-06-22 06:04:10 UTC (rev 12121)
@@ -214,7 +214,10 @@
             logo: metadata.brandLogoUri,
             copyrights: copyrights
         });
-        this.map && this.map.events.triggerEvent("changelayer", {layer: this});
+        this.map && this.map.events.triggerEvent("changelayer", {
+            layer: this,
+            property: "attribution"
+        });
     },
     
     /**

Modified: trunk/openlayers/lib/OpenLayers/Layer/GoogleNG.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/GoogleNG.js	2011-06-21 20:53:53 UTC (rev 12120)
+++ trunk/openlayers/lib/OpenLayers/Layer/GoogleNG.js	2011-06-22 06:04:10 UTC (rev 12121)
@@ -205,7 +205,10 @@
             mapType: this.type,
             mapData: mapData
         });
-        this.map && this.map.events.triggerEvent("changelayer", {layer: this});
+        this.map && this.map.events.triggerEvent("changelayer", {
+            layer: this,
+            property: "attribution"
+        });
     },
     
     /**

Modified: trunk/openlayers/lib/OpenLayers/Map.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Map.js	2011-06-21 20:53:53 UTC (rev 12120)
+++ trunk/openlayers/lib/OpenLayers/Map.js	2011-06-22 06:04:10 UTC (rev 12121)
@@ -65,12 +65,12 @@
      *      object will include a *layer* property that references the removed
      *      layer.
      *  - *changelayer* triggered after a layer name change, order change,
-     *      opacity change, params change or visibility change
-     *      (due to resolution thresholds). Listeners will receive an event
-     *      object with *layer* and *property* properties. The *layer*
-     *      property will be a reference to the changed layer. 
-     *      The *property* property will be a key to the
-     *      changed property (name, order, opacity, params or visibility).
+     *      opacity change, params change, visibility change (due to resolution
+     *      thresholds) or attribution change (due to extent change). Listeners
+     *      will receive an event object with *layer* and *property* properties.
+     *      The *layer* property will be a reference to the changed layer. The
+     *      *property* property will be a key to the changed property (name,
+     *      order, opacity, params, visibility or attribution).
      *  - *movestart* triggered after the start of a drag, pan, or zoom
      *  - *move* triggered after each drag, pan, or zoom
      *  - *moveend* triggered after a drag, pan, or zoom completes

Modified: trunk/openlayers/tests/Handler/Feature.html
===================================================================
--- trunk/openlayers/tests/Handler/Feature.html	2011-06-21 20:53:53 UTC (rev 12120)
+++ trunk/openlayers/tests/Handler/Feature.html	2011-06-22 06:04:10 UTC (rev 12121)
@@ -645,6 +645,20 @@
 
         map.destroy();
     }
+    
+    function test_layerorder(t) {
+        t.plan(2);
+        var map = new OpenLayers.Map("map");
+        var base = new OpenLayers.Layer(null, {isBaseLayer: true});
+        var vector = new OpenLayers.Layer.Vector();
+        map.addLayers([base, vector]);
+        map.addControl(new OpenLayers.Control.SelectFeature(vector, {autoActivate: true}));
+        map.zoomToMaxExtent();
+        t.eq(vector.getZIndex(), "725", "vector layer's zIndex correct");
+        map.events.triggerEvent("changelayer");
+        t.eq(vector.getZIndex(), "725", "vector layer's zIndex still correct after changelayer event");
+        
+    }
 
   </script>
 </head>



More information about the Commits mailing list