How to change attribute values of "style" element dynamically?

  • Hi,

    I have a style which has attributes such as "url", "scale" and so on.. I have many layer object which use this
    style.


    What I want to do is to change the attribute value of this style (for example "scale" attribute value) so all the

    layers which use this style are affected by this change.


    When I trace the value of the style's attribute, I can see the change is applied but nothing changes visually.


    Is this normal or is there any workaround?

    Any comments are appreciated.


    Best Regards,
    hyung

  • Hi)

    As far as I know, style is applied only when layer/hotspot is being loaded (or via loadstyle action). So if you change style properties after the style has been applied to layers/hotspots, it makes no sense. You then need to cycle through all layers/hotspots and apply those changes to each spot individually. (via for(); cycle).

    Regards,

    Alexey

  • Hi Alaxey!

    Thanks for your reply! So I have to loop through all the layers/hotspots in order to change the
    common attribute. I really wish there was a selector based on regular expression (or like jquery style).
    maybe I should ask Klaus to implement this feature.

    Best Regards,
    hyung

  • Hi,

    a 'style' is only a simple 'storage' of attributes - when a new element will be created and has a style set, then all attributes from the style will be copied to it. And for manual loading, the loadstyle action can be used.

    That's all, there is no further linkage or attribute sharing (such would make all way more complex and slower).

    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!