How do I remove the zoom-to action from the default popup? Do I have to manually remove it from the actions array via splice?
Thanks in advance,
M
Solved! Go to Solution.
Just add this to your project's CSS:
.zoomTo { display:none; }
It will hide the Zoom To link.
Steve
Just add this to your project's CSS:
.zoomTo { display:none; }
It will hide the Zoom To link.
Steve
Thanks. Nothing like a little CSS to clean things up.
You can also do it in code by clearing the popup actions, this works for me:
view.popup.viewModel.actions = [];
Steve/Mark,
In 4.0 final Popup actions will be a collection of Accessor objects, which has a visible property. So rather than use CSS you can set this property to false:
// hides zoomTo action from popup
view.popup.viewModel.actions.getItemAt(0).visible = false;
This will also make it convenient to show/hide actions based on other logic or attribute values.
This is what I used:
.esriPopup .actionsPane .zoomTo {
display: none;
}
Except for the simple solution I explained below, unfortunately none of the solutions I've found online worked for me to remove the "Zoom To" option from the default popup.
Solution: You simply need to remove the "Zoom To" action from the "actions" array. Emptying the array worked for me since I haven't added any additional actions to this array (by default, the array only contains one action: "Zoom To")
In JavaScript, there are many different ways to delete all elements of an array. What I personally did was:
view.popup.actions = [];
Above, "view" denotes the SceneView instance I created. This "view" instance might have a different name (and not necessarily has to be a SceneView) in your code but the rest should be the same...
Tip: you can always check the contents of your "actions" array by logging its contents in the console using:
var count=0;
view.popup.actions.forEach(element => {
console.log("Item " + count + " : " + element.id );
count++;
});
For more details, click here to check out the official documentation of actions in popup.
You can remove all default actions
// Removes the default actions from the popup
view.popup.viewModel.includeDefaultActions = false;
Only this solution works for me after a lot of tries. Thanks!
same here