当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS ImageryLayer.portalItem用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/layers/ImageryLayer"], (ImageryLayer) => { /* code goes here */ });

ESM: import ImageryLayer from "@arcgis/core/layers/ImageryLayer";

类: esri/layers/ImageryLayer

继承: ImageryLayer > Layer > Accessor

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

ImageryLayer.portalItem函数(或属性)的定义如下:

portalItem PortalItem


从中加载图层的门户项目。如果门户项目引用要素服务或场景服务,则您可以使用 layerId 属性指定要加载的单个图层。

从版本 4.17 开始,可以从托管在 ArcGIS Online 和 ArcGIS Enterprise 中的要素服务项目加载表。这仅适用于 feature layers ,如果 FeatureLayer.isTable 返回 true 将成功加载。

例子:

// While this example uses FeatureLayer, this same pattern can be
// used for other layers that may be loaded from portalItem ids.
const lyr = new FeatureLayer({
  portalItem: {  // autocasts as new PortalItem()
    id: "caa9bd9da1f4487cb4989824053bb847"
  }  // the first layer in the service is returned
});
// Set hostname when using an on-premise portal (default is ArcGIS Online)
// esriConfig.portalUrl = "http://myHostName.esri.com/arcgis";

// While this example uses FeatureLayer, this same pattern can be
// used for SceneLayers.
const lyr = new FeatureLayer({
  portalItem: {  // autocasts as new PortalItem()
    id: "8d26f04f31f642b6828b7023b84c2188"
  },
  // loads the third item in the given feature service
  layerId: 2
});
// This snippet loads a table hosted in ArcGIS Online.
const table = new FeatureLayer({
  portalItem: { // autocasts as esri/portal/PortalItem
    id: "123f4410054b43d7a0bacc1533ceb8dc"
  }
});

// Before adding the table to the map, it must first be loaded and confirm it is the right type.
table.load().then(function() {
  if (table.isTable) {
    map.tables.add(table);
  }
});

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 ImageryLayer.portalItem。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。