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

Layer props :paint and :layout are not reactive (but :filter is) #124

Closed
whilei opened this issue Jan 18, 2025 · 3 comments
Closed

Layer props :paint and :layout are not reactive (but :filter is) #124

whilei opened this issue Jan 18, 2025 · 3 comments

Comments

@whilei
Copy link

whilei commented Jan 18, 2025

In referencing this doc https://github.com/indoorequal/vue-maplibre-gl/blob/master/docs/examples/filter.vue,
I had expected to find that MglCircleLayer (etc.) would have reactive :paint and :layout props too,
but have found that only :filter behaves reactively.

Alternatively, I'm able to use map.map.setPaintProperty(<layer>, <key>, <val>), but... is this the only way? Is this expected behavior?

<mgl-circle-layer
        layer-id="libraries"
        source-layer="libraries"
        :paint="myPaint"
        :layout="myLayout"
        :filter="myFilter"
      />
// WORKS, OK.
const myFilter = ref(['all']); // TODO
setInterval(() => {
    myFilter.value = ['all', ['>', 'Duration', Math.floor(Math.random() * 3600-120)]];
}, 2000);

// DOES NOT WORK
const myPaint = ref({
    'circle-color': '#c81962',
    'circle-radius': 4,
});
function randomColor() {
    return '#000000'.replace(/0/g, function() {
        return (~~(Math.random() * 16)).toString(16);
    });
}
setInterval(() => {
    const next = randomColor();
    myPaint.value['circle-color'] = next;
}, 2000);

// DOES NOT WORK
const myLayout = ref({
    visibility: 'visible', // 'none'
}); 
setInterval(() => {
    myLayout.value.visibility = myLayout.value.visibility === 'visible' ? 'none' : 'visible';
}, 2000);
@francois2metz
Copy link
Member

Hi,

Thanks for raising this issue. I'll fix it.

@francois2metz
Copy link
Member

Fixed in version 8.2.1.

@whilei
Copy link
Author

whilei commented Jan 19, 2025

Wonderful, thank you!

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