I want to trigger events when the currentStyleInfo style layers' values change

202
1
03-05-2024 01:30 PM
JonathanBorgia
New Contributor

I want to trigger events when the currentStyleInfo style layers settings change. I have attempted to do so using the reactiveUtils, but the changes are not being detected. How can I achieve this? Is it possible? This is in an angular application and I would rather apply the change and detect it through a trigger from the layer than firing something that doesn't include the layer as part of the detection process.

 

 

  reactiveUtils.watch(
      () =>
        mapView.map.layers.map((layer) =>
          (layer as NavigationLayer)?.currentStyleInfo?.style.layers.map(
            (layer: any) => {
              console.log('layer = ', `${layer.id} ${layer.layout.visibility}`);
              return `${layer.id} ${layer.layout.visibility}`;
            }
          )
        ),
      (newValue, oldValue) => {
        console.table('oldValue', oldValue.toArray());
        console.table('newValue', newValue.toArray());
      }
    );

 

 

 

I know I can get it to work for the regular layer level 'visible' which is great. Just seems for things within currentStyleInfo the changes do not propagate as watchable

 

 

 reactiveUtils.watch(
      () => mapView.map.layers.map((layer) => layer.visible),
      (newValue, oldValue) => {
        console.table(oldValue.toArray());
        console.table(newValue.toArray());
      }
    );

 

 

 

Thank you all ahead of time.

0 Kudos
1 Reply
SamLibby
Esri Contributor

Hi Jonathan,

 

I worked with some folks on the development team to confirm this is not possible at this time - managing map state in another way will be required. If this continues to be of interest, please submit an Enhancement Request through the Support Site so we can track interest in adding that feature. 

0 Kudos