英文:
How do I remove the untitled layer from my layer list in JavaScript?
问题
我正在使用HTML、CSS和JavaScript创建一个Web应用程序,具体来说是使用ArcGIS JavaScript API。我已经创建了一个图层列表,以便用户可以打开和关闭他们想要的特定图层。然而,有一个未命名的图层,我不确定它在哪里。当我尝试从图层列表中关闭它时,地图上没有任何变化,这表明没有数据可以切换开关。我已经进行了几周的调试,但一无所获,所以我真的很需要一些帮助。下面是显示确切问题的屏幕截图。
我的图层列表代码如下:
view.when(() => {
const layerList = new LayerList({
view: view,
visible: false,
selectionEnabled: true
});
const expand = new Expand({
view: view,
content: layerList
});
// 将微件添加到视图的右上角
view.ui.add(expand, "top-left");
});
英文:
I am creating a web application using html, CSS and JavaScript, specifically arcgis JavaScript API. I have created a layer list so that users can turn on and turn off the specific layers they want. However, there is a untitled layer and I am not sure where it is. When I try to turn it off from the layer list nothing moves from the map which suggests there is no data to toggle on or off. I have done weeks of debugging and I am getting nowhere so I would really appreciate some help. The screenshot showing the exact issue is below.
My code for the layer list looks like this:
view.when(() => {
const layerList = new LayerList({
view: view,
visible: false,
selectionEnabled: true
});
const expand = new Expand({
view: view,
content: layerList
});
// Add widget to the top right corner of the view
view.ui.add(expand, "top-left");
});
答案1
得分: 0
你可以提供更多细节吗?也许有一个可工作的 CodePen 示例吗?
你的 JavaScript 代码没问题。看起来在某个地方确实创建了一个名为 "Untitle Layer" 的地图图层。在这种情况下,你可以使用 ListItemPanel widget 中的 listItemCreatedFunction 来确保不渲染特定项目。
英文:
Can you provide more detail? Maybe working codepen?
Your JS is ok. Looks like someone along the way actually created a map layer named "Untitle Layer". That being the case you can use the listItemCreatedFunction in the ListItemPanel widget to make sure that specific item is not rendered.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论