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

08-07-2020 03:59 AM
New Contributor


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

0 Kudos
2 Replies
Frequent Contributor II

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

  ({ value, state }) => {
    if (state !== "stop") return;
    const fr = layer.featureReduction.clone();
    fr.clusterRadius = value;
    layer.featureReduction = fr;

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
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