I know there is a setBaseLayer function in OpenLayers 2. Is there a way I can accomplish that in OpenLayers 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, gis.stackexchange.com/questions/73982/…– John PowellCommented Oct 10, 2014 at 15:42
-
What are you trying to achieve? There is likely to be another way of doing it.– John PowellCommented Oct 10, 2014 at 15:43
-
1You're right. Getting all the layers and just insert a layer at index 0 did the trick.– JazonCommented Oct 14, 2014 at 17:27
Add a comment
|
1 Answer
You can set the base layer by doing:
var layers = this.map.getLayers();
layers.insertAt(0, base_layer);
-
Well done. I haven't had time to wrap my head round OL3 yet, so good to see things like this being posted. Commented Oct 14, 2014 at 18:01
-
I'm not sure this worked but this doesn't really work for now. Commented Dec 7, 2017 at 2:03