Make clear how to remove an unmanaged layer from a map
This commit is contained in:
@@ -149,8 +149,9 @@ ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() {
|
|||||||
/**
|
/**
|
||||||
* Sets the layer to be rendered on a map. The map will not manage this layer in
|
* Sets the layer to be rendered on a map. The map will not manage this layer in
|
||||||
* its layers collection, and the layer will be rendered on top. This is useful
|
* its layers collection, and the layer will be rendered on top. This is useful
|
||||||
* for temporary layers. To add the layer to a map and have it managed by the
|
* for temporary layers. To remove an unmanaged layer from the map, use
|
||||||
* map, use {@link ol.Map#addLayer} instead.
|
* `#setMap(null)`. To add the layer to a map and have it managed by the map,
|
||||||
|
* use {@link ol.Map#addLayer} instead.
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol.Map} map Map.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -586,10 +586,17 @@ describe('ol.layer.Layer', function() {
|
|||||||
};
|
};
|
||||||
map.dispatchEvent(new ol.render.Event('precompose', map, null,
|
map.dispatchEvent(new ol.render.Event('precompose', map, null,
|
||||||
frameState, null, null));
|
frameState, null, null));
|
||||||
var layerState = frameState.layerStatesArray[0];
|
|
||||||
expect(frameState.layerStatesArray.length).to.be(1);
|
expect(frameState.layerStatesArray.length).to.be(1);
|
||||||
|
var layerState = frameState.layerStatesArray[0];
|
||||||
expect(layerState.layer).to.equal(layer);
|
expect(layerState.layer).to.equal(layer);
|
||||||
expect(frameState.layerStates[goog.getUid(layer)]).to.equal(layerState);
|
expect(frameState.layerStates[goog.getUid(layer)]).to.equal(layerState);
|
||||||
|
frameState.layerStatesArray = [];
|
||||||
|
frameState.layerStates = {};
|
||||||
|
|
||||||
|
layer.setMap(null);
|
||||||
|
map.dispatchEvent(new ol.render.Event('precompose', map, null,
|
||||||
|
frameState, null, null));
|
||||||
|
expect(frameState.layerStatesArray.length).to.be(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user