Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic filter of layer #216

Open
umsiw opened this issue Dec 9, 2024 · 1 comment
Open

Dynamic filter of layer #216

umsiw opened this issue Dec 9, 2024 · 1 comment

Comments

@umsiw
Copy link

umsiw commented Dec 9, 2024

Is it possible to filter a layer dynamically? For example, I have defined a layer as follows:

"id": 38,
"name": "River",
"type": "line",
"filter": [
    "match",
    ["get", "class"], 
    ["river_filter"],  // custom value of river_filter defined dynamically
    true,
    false
],
"source": {
    "type": "vector",
    "tiles": ["${API_URL}"]
},
"layout": {
    "visibility": "visible"
}

with HTML as follow:

<mgl-layer
        [id]="layer.name"
        [type]="layer.type"
        [source]="layer.source"
        [layout]="layer.layout"
        [filter]="layer.filter"
></mgl-layer>

Is it possible to define the variable river_filter dynamically in order to filter features on the layer? Or is there another approach to dynamically filter layers? I was able to do it when the value is predefined (static).

Thank you for any feedback or suggestions.

@HarelM
Copy link
Collaborator

HarelM commented Dec 9, 2024

Check out the docs, it depends if this is an input only properly or not.
If not, then changing the filler at runtime works require removing and adding the layer back, which is hard for maplibre due to ordering etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants