4

According to OpenLayers 3 documentation, the function

addLayer(layer)

Adds the given layer to the top of this map.

How can I add a layer to the bottom of a map?

P.S. I need this to add a background layer similar to a base layer in OpenLayers 2.

8

It seems that I found a solution after some trial and error, i.e. simply use a map's layers collection, and insert layer to the head position:

var layers = map.getLayers();
layers.insertAt(0,layer);
  • Do you have a working example of this? I seem to have come across a similar issue but can't get it to work – Joshua Dickerson Sep 17 '15 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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