Hide DistanceMeasurement2D-layer in LayerList

209
2
Jump to solution
03-29-2019 08:19 AM
MichaelLodes2
Occasional Contributor

(API 4.11)

Hi,

as in the title i am trying to hide the layer, that the DistanceMeasureMent2D widget saves its Graphics on, in the LayerList widget. As i have no access to the layer i cannot set  the listMode to hide (listMode: "hide").

Defining the operationalItems in the layerList is not the optimal solution as we wan't to change the layers dynamically via php.

A small workaround i found in the GeoNet would be to not allow any Graphicslayers in the Layerlist widget:

var layerList = new LayerList({
view: view,
container: document.createElement("div"),
listItemCreatedFunction: defineActions
});

layerList.operationalItems.on("before-add", function(event){
if (event.item.layer.type === "graphics") {
event.preventDefault();
}
});‍‍‍‍‍‍‍‍‍‍‍

That works fine for the moment but maybe in the Future we might want to have graphicslayers included.

Changing the LayerListView.js is also not an option.

tl;dr: How to access and hide the DistanceMeasurement2D-layer in the LayerList widget?

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Hi Michael, I'm pretty sure we fixed this at 4.11 to be the default behavior. Here is a sample app that demonstrates how the 2D area and distance measurements are not added to the LayerList widget:

https://codepen.io/noash/pen/MRgJvK

View solution in original post

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

Hi Michael, I'm pretty sure we fixed this at 4.11 to be the default behavior. Here is a sample app that demonstrates how the 2D area and distance measurements are not added to the LayerList widget:

https://codepen.io/noash/pen/MRgJvK

View solution in original post

0 Kudos
MichaelLodes2
Occasional Contributor

Thank you, i just checked it and can confirm the layer doesn't show up in the Layerlist anymore. Was just moving to 4.11 while in the process of trying to hide that item.