Activating strategies after adding the layer to the map. r=elemoine (closes #1920)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9266 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -529,6 +529,14 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: afterAdd
|
||||
* Called at the end of the map.addLayer sequence. At this point, the map
|
||||
* will have a base layer. To be overridden by subclasses.
|
||||
*/
|
||||
afterAdd: function() {
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: removeMap
|
||||
* Just as setMap() allows each layer the possibility to take a
|
||||
|
||||
@@ -350,6 +350,15 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
this.renderer.map = this.map;
|
||||
this.renderer.setSize(this.map.getSize());
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: afterAdd
|
||||
* Called at the end of the map.addLayer sequence. At this point, the map
|
||||
* will have a base layer. Any autoActivate strategies will be
|
||||
* activated here.
|
||||
*/
|
||||
afterAdd: function() {
|
||||
if(this.strategies) {
|
||||
var strategy, i, len;
|
||||
for(i=0, len=this.strategies.length; i<len; i++) {
|
||||
|
||||
@@ -926,6 +926,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
}
|
||||
|
||||
this.events.triggerEvent("addlayer", {layer: layer});
|
||||
layer.afterAdd();
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -455,6 +455,21 @@
|
||||
|
||||
}
|
||||
|
||||
function test_afterAdd(t) {
|
||||
|
||||
t.plan(1);
|
||||
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer(null, {isBaseLayer: true});
|
||||
var hasBase = false;
|
||||
layer.afterAdd = function() {
|
||||
hasBase = !!(layer.map && layer.map.baseLayer);
|
||||
}
|
||||
map.addLayer(layer);
|
||||
t.eq(hasBase, true, "when afterAdd is called, map has a base layer");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******
|
||||
|
||||
Reference in New Issue
Block a user