3

I have several base layers added to a map in an OpenLayers based application. There is only one that can be displayed at a time, as they are all base layers.

When the user changes the selected base layer, I store the name of the selected layer as a HTML5 local storage item (an improved cookie). When re-opening the application, I want to programmatically set the same base layer be displayed.

It works fine with layer.visibility = true if isBaseLayer is false, but not in the case when isBaseLayer is set to true.

Is there anything else I could try for this?

1 Answer 1

6

A combination of map.getLayersByName(name) and map.setBaseLayer(layer) should do this for you.

0

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.