當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。