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


JavaScript ArcGIS LayerList.listItemCreatedFunction用法及代碼示例

基本信息

以下是所在類或對象的基本信息。

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

ESM: import LayerList from "@arcgis/core/widgets/LayerList";

類: esri/widgets/LayerList

繼承: LayerList > Widget > Accessor

自從:用於 JavaScript 4.2 的 ArcGIS API

用法說明

LayerList.listItemCreatedFunction函數(或屬性)的定義如下:

listItemCreatedFunction ListItemCreatedHandler


自從:ArcGIS 適用於 JavaScript 4.4 的 API

每次創建或修改ListItem 時執行的函數。使用此函數可將操作和麵板添加到列表項,並覆蓋列表項的默認設置。可以使用 ListItem 的 actionsSections 屬性將操作添加到列表項。

例子:

let layerList = new LayerList({
  view: view,
  // executes for each ListItem in the LayerList
  listItemCreatedFunction: function (event) {

    // The event object contains properties of the
    // layer in the LayerList widget.

    let item = event.item;

    if (item.title === "US Demographics") {
      // open the list item in the LayerList
      item.open = true;
      // change the title to something more descriptive
      item.title = "Population by county";
      // set an action for zooming to the full extent of the layer
      item.actionsSections = [[{
        title: "Go to full extent",
        className: "esri-icon-zoom-out-fixed",
        id: "full-extent"
      }]];
    }
  }
});

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 LayerList.listItemCreatedFunction。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。