How to implement cluster radius dynamically through a slider in api 4?

378
2
08-07-2020 03:59 AM
ArunRaj1
New Contributor

Hi,

I want to update the cluster radius using a slider in esri api 4.15. Any references

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor

You can use the provided Slider widget with the API, clone the FeatureReductionCluster, and update the clusterRadius.

slider.on(
  "thumb-drag",
  ({ value, state }) => {
    if (state !== "stop") return;
    const fr = layer.featureReduction.clone();
    fr.clusterRadius = value;
    layer.featureReduction = fr;
  }
);‍‍‍‍‍‍‍‍‍

https://codepen.io/odoe/pen/JjXoaNX?editors=1000 

If you try to do it on each tick change, even if you debounce the function, you get some artifacts along the tiles of the cluster calculations. Better to wait for the slider to stop and then update.

0 Kudos
ArunRaj1
New Contributor

Thanks Rene Rubalcava‌ Seems a nice one, will check on this. By the way, dorefresh() on featureReduction is not working(the method which i tried - assigned the new clusterRadius value to the layer and initiated doRefresh()).

0 Kudos