I know there is a setBaseLayer function in OpenLayers 2. Is there a way I can accomplish that in OpenLayers 3?
Asked
Active
Viewed 5,106 times
3
-
As far as I know, there is no concept of a baselayer in OL3, you can have multiple layers, and you can set visibility on them. This might help, http://gis.stackexchange.com/questions/73982/openlayers-3-layer-visibility – John Powell Oct 10 '14 at 15:42
-
What are you trying to achieve? There is likely to be another way of doing it. – John Powell Oct 10 '14 at 15:43
-
1You're right. Getting all the layers and just insert a layer at index 0 did the trick. – Jazon Oct 14 '14 at 17:27
1 Answers
10
You can set the base layer by doing:
var layers = this.map.getLayers();
layers.insertAt(0, base_layer);
Jazon
- 231
- 2
- 11
-
Well done. I haven't had time to wrap my head round OL3 yet, so good to see things like this being posted. – John Powell Oct 14 '14 at 18:01
-