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


JavaScript ArcGIS Sublayer.createFeatureLayer用法及代码示例


基本信息

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

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

ESM: import Sublayer from "@arcgis/core/layers/support/Sublayer";

类: esri/layers/support/Sublayer

继承: Sublayer > Accessor

自从:用于 JavaScript 4.1 的 ArcGIS API

用法说明

Sublayer.createFeatureLayer函数(或属性)的定义如下:

createFeatureLayer () {Promise<FeatureLayer>}


自从:ArcGIS 适用于 JavaScript 4.7 的 API

一种基于子层配置创建FeatureLayer 实例的便捷方法,包括dynamic sources。这允许您利用子层中不支持的 FeatureLayer 函数,例如 Smart Mapping creator functions

返回:

类型 说明
Promise<FeatureLayer> 解析为 FeatureLayer 的 Promise 与调用此方法的子层实例的配置相匹配。

例子:

let sublayer = mapImageLayer.findSublayerById(0);

// when the createFeatureLayer() promise resolves, load the FeatureLayer
// and pass it to the createParameters function
sublayer.createFeatureLayer()
  .then(function(featureLayer){
    return featureLayer.load();
  })
  .then(createParameters);

function createParameters (featureLayer) {
  let colorParams = {
    layer: featureLayer,
    basemap: map.basemap,
    field: "POPULATION",
    normalizationField: "SQ_MILES",
    legendOptions: {
      title: "Population density (sq. miles)"
    }
  };
}

// when the promise resolves, apply the renderer to the sublayer
colorRendererCreator.createContinuousRenderer(colorParams)
  .then(function(response){
    sublayer.renderer = response.renderer;
  });

相关用法


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