# Setting isBaseLayer to true on added layer?

**URL:** <https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787>\
**Category:** CesiumJS\
**Created:** [October 18, 2013, 8:59am UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787 "2013-10-18T08:59:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.dunnage](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@adam.dunnage](https://community.cesium.com/u/adam.dunnage)\
**Post date:** [October 18, 2013, 8:59am UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787/1 "2013-10-18T08:59:43Z")

</div>

I currently have this function for adding base layers:

function addBaseLayerOption(name, imageryProvider, alpha, show) {  
&nbsp;&nbsp;var layer = imageryLayerCollection.addImageryProvider(imageryProvider);  
&nbsp;&nbsp;layer.alpha = Cesium.defaultValue(alpha, 0);  
&nbsp;&nbsp;layer.show = Cesium.defaultValue(show, true);  
&nbsp;&nbsp;layer.name = name;  
}

When these layers are being added however they are not being set to isBaseLayer true. How can I set it so that each layer that is added the isBaseLayer is set to true?

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [October 18, 2013, 2:49pm UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787/2 "2013-10-18T14:49:22Z")

</div>

Hi Adam,

Only one layer (the base one) can be the base layer. What are you actually trying to do?

Kevin

---

<div class="post-metadata">

**Author:** ![adam.dunnage](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@adam.dunnage](https://community.cesium.com/u/adam.dunnage)\
**Post date:** [October 21, 2013, 8:29am UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787/3 "2013-10-21T08:29:13Z")

</div>

I have managed to get around this problem but have hit another in doing this. I have an application which starts up and when it does places a layer on the globe for example:

var blackMarble = layers.addImageryProvider(new Cesium.TileMapServiceImageryProvider({  
&nbsp;&nbsp;&nbsp;&nbsp;url : ‘[http://cesium.agi.com/blackmarble](http://cesium.agi.com/blackmarble)’,  
&nbsp;&nbsp;&nbsp;&nbsp;maximumLevel : 8,  
&nbsp;&nbsp;&nbsp;&nbsp;credit : ‘Black Marble imagery courtesy NASA Earth Observatory’  
}));

I then have my own toolbox of buttons for different layers to add. When a button is clicked then a new layer is added and the starting layer is removed like so:

&nbsp;&nbsp;&nbsp;&nbsp;function addBaseLayerOption(name, imageryProvider, alpha, show) {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var layer = imageryLayerCollection.addImageryProvider(imageryProvider, 1);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layer.alpha = Cesium.defaultValue(alpha, 0);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layer.show = Cesium.defaultValue(show, true);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;layer.name = name;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var layer2 = imageryLayerCollection.get(0);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;imageryLayerCollection.remove(layer2);  
&nbsp;&nbsp;&nbsp;&nbsp;}

However the layer is then not displayed and all that is displayed is plain blue view on the globe as if there are no layers. I have check in Chrome dev tools in the imageryLayerCollection and the layer is there and isBaseLayer is true so by my understanding the layer should be displayed should it not?

---

<div class="post-metadata">

**Author:** ![adam.dunnage](https://avatars.discourse-cdn.com/v4/letter/a/977dab/32.png) [@adam.dunnage](https://community.cesium.com/u/adam.dunnage)\
**Post date:** [October 21, 2013, 9:47am UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787/4 "2013-10-21T09:47:59Z")

</div>

Not to worry I have managed to solve this.

---

<div class="post-metadata">

**Author:** ![Daniel\_Santillan](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@Daniel\_Santillan](https://community.cesium.com/u/Daniel_Santillan)\
**Post date:** [October 28, 2014, 9:17am UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787/5 "2014-10-28T09:17:02Z")

</div>

Hi, it has been some time since your post, but i have the same exact problem (using my own tools to manage the layers), when i set show to false for one layer and another to true, the globe just stays blue, without requesting the new tiles. If a switch one more time curiously it loads the tiles.  
From what i can see i create the layers pretty much as you did.

how did you solve this?

---

<div class="post-metadata">

**Author:** ![Daniel\_Santillan](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@Daniel\_Santillan](https://community.cesium.com/u/Daniel_Santillan)\
**Post date:** [October 28, 2014, 10:04am UTC](https://community.cesium.com/t/setting-isbaselayer-to-true-on-added-layer/787/6 "2014-10-28T10:04:58Z")

</div>

Hi, managed to solve the problem. It was my fault, when setting the show property of the layer i used a wrong getter and i imagine it was undefined. When i set the show value of each layer correctly it worked as expected.

Kind regards!
