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.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityAccording 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.
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);