0

This might be a noob question. I have a wms layer in OpenLayers 2.13.1 with attribution: "some_text" set when it's added. This is working fine, the attribution shows up fine in the map div.

My question is how to change the content of the attribution param when the layer is already added. So far I have tried myWMS_layer.mergeNewParams({attribution: "some_updated_text"}); but no luck. I've also find updateAttribution function in OpenLayers docs, but don't really know how to use it. I've tried myAttributionControl.updateAttribution(); and nothing happened.

Thanks in advance!

2 Answers 2

1

Finally I found the trick. When an attribution control is created, OL actually creates a DOM element with class name .olControlAttribution.

So with simple jquery, we can update the content with: $(".olControlAttribution").html("some_updated_text"); Nice thing is, since it's DOM element, we can put any html tag inside it; including <img> which is pretty useful for showing map legend.

Anyway, I'm open for any other more proper ways to do this. Cheers!

0

For me it worked by forcefully redrawing the layer after changing the attribution:

myWMS_layer.attribution = "some_updated_text";
myWMS_layer.redraw (true);

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.