I have been using map.setBaseLayer(layer);
to switch to my preferred map layer, using the localStorage variable layer
that is stored in my web browser, upon initialization of the map. But I realize that this is creating unnecessary calls to load the default (first layer) map tiles that I may not need if the preferred layer is the second or third one. Is there a way that I can pre-select the base layer to be displayed (before map initialization), without changing the order of the map layers?
[GIS] How to set the base layer of map before initialization
layersopenlayers-2
Best Answer
map.baseLayer = your-layer
OpenLayers add the first baselayer in map.baseLayer property but calls it only when add to map. So you can change the layer before being called.