1

How can I have the style of the features on a vector layer depending on the OpenLayers' "base layer"?

For example, some base layers are dark images and I need (for the contrast) the features to be displayed bright in the vector layer upon the base layer. And as soon as base layer changes to a bright one, features should be redrawn dark.

How can I achieve this with OpenLayers code?

0

You can do this using a Stylemap and a context function.

This example shows it in operation http://openlayers.org/dev/examples/styles-context.html

Your function would return the value based upon the features layer, eg:-

var context = {
            getColor: function(feature) {
                var baselayer = feature.map.baseLayer;

                ... 

                SELECT and return your color based upon the baselayer 
                ...
            }
        };
1
  • What actually worked was feature.layer.map.baseLayer.name.toString() for selection based upon the baselayer name – user32916 Aug 27 '14 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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