-
map
(callback)
{Collection}
將每個 Collection 項傳遞給
callback
函數並返回一個包含返回值的新數組。例如,如果您有一個數字集合並希望將每個數字加 10,則可以使用map()
創建一個新集合,其中相同的數字加 10。參數:
類型 說明 callback ItemMapCallback處理集合中的每個項目並在原始項目的相同索引處返回新值的函數。
返回:
類型 說明 Collection 返回一個新集合,其中包含從 callback
生成的新項目。例子:
// Gets the geometries of the graphics and assigns them to a new Collection let geoms = graphicsLayer.graphics.map(function(item, i){ return item.geometry; });
基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/core/Collection"], (Collection) => { /* code goes here */ });
ESM:
import Collection from "@arcgis/core/core/Collection";
類:
esri/core/Collection
繼承: Collection > Accessor
自從:用於 JavaScript 4.0 的 ArcGIS API
用法說明
Collection.map
函數(或屬性)的定義如下:
相關用法
- JavaScript ArcGIS Collection.addMany用法及代碼示例
- JavaScript ArcGIS Collection.add用法及代碼示例
- JavaScript ArcGIS Collection.lastIndexOf用法及代碼示例
- JavaScript ArcGIS Collection.ofType用法及代碼示例
- JavaScript ArcGIS Collection.pop用法及代碼示例
- JavaScript ArcGIS Collection.reverse用法及代碼示例
- JavaScript ArcGIS Collection.find用法及代碼示例
- JavaScript ArcGIS Collection.removeMany用法及代碼示例
- JavaScript ArcGIS Collection.toArray用法及代碼示例
- JavaScript ArcGIS Collection.some用法及代碼示例
- JavaScript ArcGIS Collection.remove用法及代碼示例
- JavaScript ArcGIS Collection.concat用法及代碼示例
- JavaScript ArcGIS Collection.unshift用法及代碼示例
- JavaScript ArcGIS Collection.splice用法及代碼示例
- JavaScript ArcGIS Collection.sort用法及代碼示例
- JavaScript ArcGIS Collection.every用法及代碼示例
- JavaScript ArcGIS Collection.push用法及代碼示例
- JavaScript ArcGIS Collection.indexOf用法及代碼示例
- JavaScript ArcGIS Collection.slice用法及代碼示例
- JavaScript ArcGIS Collection.forEach用法及代碼示例
- JavaScript ArcGIS Collection.includes用法及代碼示例
- JavaScript ArcGIS Collection.findIndex用法及代碼示例
- JavaScript ArcGIS Collection.shift用法及代碼示例
- JavaScript ArcGIS Collection.filter用法及代碼示例
- JavaScript ArcGIS Collection.join用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 Collection.map。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。