0

Using ArcGIS Maps SDK for JavaScript version 4.x, it is possible for the view's popup to contain an array of features. In this case, it is possible to page through them using the forward/back arrows.

Assume I wish to remove one of the features from the popup's features array programatically, so that it doesn't display in the popup. How can I do this cleanly?

In this simple example, I manually remove the first feature from the array, and it is no longer possible to navigate forward/back in the popup. However, the forward/back buttons remain and the popup still lists "2 of 2" features.

enter image description here

(This is a simplistic example, and in reality I would use some logic to determine which of the features to delete.)

clear removes all features, but I only wish to remove certain features programatically.

How can I remove the feature and also decrement the feature counter?

1 Answer 1

2

It seems that ArcGIS Maps SDK JD does not detect change of view.popup.features array if it's done by just overwriting original array with the JS .splice method. On possible solution is to create a new array and assign it to view.popup.features.

Code could then look something like this (tested):

reactiveUtils.watch(
  () => view.popup.features,
  () => {
    if (view.popup.features.length > 1){
      view.popup.features.splice(0, 1);
      view.popup.features = [].concat(view.popup.features);
    }
  });
});
1
  • now I feel stoopid for not testing something so simple ;) Commented Jul 18, 2023 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.