3

I know there is a setBaseLayer function in OpenLayers 2. Is there a way I can accomplish that in OpenLayers 3?

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/… Commented Oct 10, 2014 at 15:42
  • What are you trying to achieve? There is likely to be another way of doing it. Commented Oct 10, 2014 at 15:43
  • 1
    You're right. Getting all the layers and just insert a layer at index 0 did the trick.
    – Jazon
    Commented Oct 14, 2014 at 17:27

1 Answer 1

10

You can set the base layer by doing:

var layers = this.map.getLayers();
layers.insertAt(0, base_layer);
2
  • 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.
    – Chase Choi
    Commented Dec 7, 2017 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.