javascript - 如何通过 react-arcgis npm 将图层添加到 arcgis map ?

标签 javascript reactjs arcgis arcgis-js-api esri-maps

我正在尝试使用 react-arcgis npm 向 arcgis 添加一个图层,

esriPromise(["esri/layers/TileLayer"]).then(([ TileLayer ]) => {
            var initLayer = new TileLayer({
                url: "http://......."
            });
            console.log(initLayer);
            this.setState({ layer: initLayer });

        });

但我对大多数属性的输出为空。

另外,当我尝试将图层属性添加到 map 时,出现以下错误,

[esri.core.Accessor] Accessor#set Assigning an instance of 'esri.layers.TileLayer' which is not a subclass of 'esri.core.Collection'

<div id = 'main-content'>
  <Map
    class="full-screen-map"
    mapProperties={{
      basemap: 'topo',
      showLabels : true,
      logo: false,
      sliderPosition: 'bottom-left',
      layers: this.state.layer,
    }}
    viewProperties={{
      layers: this.state.layer,
      zoom: 12,
      extent: this.state.extent,
      minZoom: minZoom,
      maxZoom: maxZoom,
    }}
    onFail={this.handleFail}
    onLoad={this.handleMapLoad}
  />
</div>

任何帮助将不胜感激......

最佳答案

图层是一个集合。我一直在通过一个单层。 我所要做的就是制作一个“层”状态数组并将该层传递给数组

关于javascript - 如何通过 react-arcgis npm 将图层添加到 arcgis map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48575484/

相关文章:

javascript - Mongoose 在两个参数中搜索一个值

javascript - 如何在javascript中获取放置在中继器内的特定标签的文本

reactjs - 在两个 React 应用程序之间共享组件

python - 尝试删除要素服务 Python API 1.7 for ArcGIS 中的要素时出现错误消息

javascript - 让简单的搜索算法更优雅

javascript - 如何向 Mocha 输出报告添加文本

javascript - 在 "Cannot convert undefined or null to object"导航栏中使用 "Collapse"时为 "reactstrap"

reactjs - 在组件类之外使用react更新组件 Prop

python - Python ArcGIS 字段计算器中的 If/else 语句

ArcGIS 字段计算器中的 Python 语法错误