I have an OpenLayers map with allOverlays set to true. Im adding 3 layers to the map. First, my own rendered version of OSM data (but only for levels 8-16), secondly an orthophoto layer (for levels 13-19) and 3rd layer is a vector, defined on all levels. Order is important, because of overlaying. Also, note that resolutions array i pass into the map object has no effect.

If i initialize the map in this way:

    map = new OpenLayers.Map('map_canvas', 
    projection: p3857,
    displayProjection: p4326,

    resolutions: [156543.0339, 78271.51695, 39135.75848, 19567.87924, 9783.939619, 4891.969809, 2445.984905, 1222.992452, 611.4962262, 305.7481131, 152.8740565, 76.43702827, 38.21851414, 19.10925707, 9.554628534, 4.777314267, 2.388657133, 1.194328567, 0.597164283, 0.298582142, 0.149291071, 0.074645535],
    allOverlays: true,
    controls: [new OpenLayers.Control.Navigation(), 
               new OpenLayers.Control.LayerSwitcher({'ascending':false})]

...and add the layers in the order i specified, i have a problem, because of allOverlays: true it assumes the OSM layer as the fictional base layer (because its the first one added to the map) from which the map calculates its properties. These are incorrect because that layer isnt defined for all resolutions. I then simply copied the initialization code for my vector layer in front of XYZ layer (with OSM data) initialization and then it works ok, but the vector layer is rendered twice of course. I want to get rid of this dummy first layer which is needed to correctly initialize the map object. How can i do that?

I suppose i could use some world coastline shapefile and render it, but if its possible i'd rather just remove it somehow.

2 Answers 2


You can create a blank layer and use it as the base layer.

base = new OpenLayers.Layer("",{isBaseLayer: true});
  • @U2ros Glad it worked. :)
    – R.K.
    May 24, 2013 at 7:06
map.addLayer(new OpenLayers.Layer("EmptyLayer", { isBaseLayer: true, visibility: true, transparent: true, displayInLayerSwitcherBase: true }));

this line is for adding an empty base layer and show it in the switcher

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.