Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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],
    units:'m',
    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.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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

base = new OpenLayers.Layer("",{isBaseLayer: true});
share|improve this answer
    
Brilliant suggestion. Thank you –  U2ros Oct 10 '12 at 14:14
    
Thanks! Very helpful! –  Stefan May 24 '13 at 6:55
    
@U2ros Glad it worked. :) –  R.K. May 24 '13 at 7:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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