Hi,
I would like to know if someone knows how change symbology style for a layer with a .qml plugin?
For exemple, i have a points layer with a cluster symbology and another style without cluster symbology and i would like change this style via a qml plugin.
@woupss , that’s not yet possible. It’s a relatively complex set of scenarios here (having to deal both with renderers and their associated symbol(s)). It’s something I’d love to brainstorm about with other plugin developers on how we could have something useful unlocked on that front.
I don’t have much experience with styling. Still, since you can configure multiple styling layers and enable/disable them based on expressions, you could store which styling layer to use for a given feature ID and determine the styling a feature should use based on the queried information.
A plugin can access that hidden layer to change its values based on in-app events.
As an example, since almost all attributes inside a styling layer can be set using expressions, instead of the “styling layer to use” you could store a color, and this way give each cluster a different color.
Never used this, so I don’t know how performant this would be, or if this would even work.
And I’m not sure I understood your endgoal correctly, but I still hope this idea is useful in some way!
I don’t see why it wouldn’t. If you make your hidden data structure complex enough, you should be able to use it with everything you can query expressions for.
Let me break down my color example a bit more so it might be easier for you to adapt to your use case.
Let’s say we call our hidden layer could look like this:
id
feature_id
color_hex
Your expression for the color could then look up the color for the current feature and default to blue, while your plugin could allow you to select a color for all currently selected features and store it in the hidden layer. In theory, if you, e.g., select features 2 and 7 and set them to green using the plugin, both those features should then be green instead of blue, while all the other ones are still blue. Your hidden layer would then look something like this:
id
feature_id
color_hex
1
2
#008000
2
7
#008000
Since the project needs a certain structure with the hidden-layer approach, I don’t think it would be a good fit for a public app plugin anyway.
It’s a bit convoluted, but I still hope that helps!
Edit: Data wise it should be similar to what we did with our Project Plugin for Feature Voting , that’s where I got the idea from when I read your question.
Thanks Pascal
Actually i made it works with map themes and the plugin to change layers styles.
But there is a limitation, i can’t show or hide a layer when a layer is in private mode
So actually i need to show my points layers and hide it when there is not plugin filter active and show layer when plugin filter is active