Map.addLayer() will return false when adding duplicate layers. Fixes #248.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2539 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -299,6 +299,12 @@ OpenLayers.Map.prototype = {
|
||||
* @param {OpenLayers.Layer} layer
|
||||
*/
|
||||
addLayer: function (layer) {
|
||||
for(var i=0; i < this.layers.length; i++) {
|
||||
if (this.layers[i] == layer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
layer.div.style.overflow = "";
|
||||
this.setLayerZIndex(layer, this.layers.length);
|
||||
|
||||
|
||||
@@ -220,6 +220,20 @@
|
||||
t.ok( gotLayer == null, "getLayer correctly returns null when layer not found");
|
||||
}
|
||||
|
||||
function test_11_Map_double_addLayer(t) {
|
||||
t.plan( 1 );
|
||||
map = new OpenLayers.Map($('map'));
|
||||
layer = new OpenLayers.Layer.WMS('Test Layer',
|
||||
"http://octo.metacarta.com/cgi-bin/mapserv",
|
||||
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}
|
||||
);
|
||||
|
||||
map.addLayers([layer,layer]);
|
||||
|
||||
t.eq( map.layers.length, 1, "Map does not allow double adding of layers." );
|
||||
|
||||
}
|
||||
|
||||
function test_10_Map_setBaseLayer(t) {
|
||||
t.plan( 4 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user