如何通过 react-arcgis npm 向 ArcGIS 地图添加图层



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

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

但是我得到大多数属性的空输出。

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

[esri.core.Accessor] Accessor#set 分配 的实例 'esri.layers.TileLayer' 它不是 '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>

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

Layers是一个集合。我一直在通过一层它自己。我所要做的就是制作一个"layer"状态的数组并将该层传递给数组

最新更新