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

modify js script in stylesheet #2624

Open
YHLpuyu opened this issue Sep 11, 2024 · 1 comment
Open

modify js script in stylesheet #2624

YHLpuyu opened this issue Sep 11, 2024 · 1 comment

Comments

@YHLpuyu
Copy link

YHLpuyu commented Sep 11, 2024

is there any solution that I can modify the script in stylesheet?
I add a FeatureModelLayer and create a script for stylesheet, for render shapefile. In code, I create a array for stores feature.id, which those features I interested, there maybe more than one array, each array has own style. for example: the layer total has 6 features, I choose first 3 features for array A, others for array B. A=[1,2,3], B=[4,5,6], the number is feature.id, and use below function:

function getClass()
{
    if(feature.id in [1,2,3]) return "normalstyle";
    else if(feature.id in [4,5,6] return "otherstyle";
}

after some operations, A=[1,2,3,5], B=[4], and I generate std::string by replace the array in JS. So the script like below:

function getClass()
{
    if(feature.id in [1,2,3,5]) return "normalstyle";
    else if(feature.id in [4]) return "otherstyle";
}

after call featuremodellayer.dirty() the render image is same as before. there are no difference;
means the script is not update
I check the code in FeatureModelGraph, the _session is create after add to map, and never changed. _session only rebuild scriptengine when styles() is not set, however when add to map, the stylesheet of session has been seted, and never changed.
May I miss some thing, about update script? Or I need modify the source code?
Thanks for any help.

@gwaldron
Copy link
Owner

No, unfortunately there is no way to change the script dynamically. This would be a new feature request. Let us know if you come up with another solution!

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