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


JavaScript ArcGIS Collection.indexOf用法及代码示例


基本信息

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

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

ESM: import Collection from "@arcgis/core/core/Collection";

类: esri/core/Collection

继承: Collection > Accessor

子类: SceneModifications

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

Collection.indexOf函数(或属性)的定义如下:

indexOf (searchElement, fromIndex) {Number}


返回集合中元素的索引。

参数:

类型说明
searchElement *

要在集合中搜索的项目。

fromIndex Number
可选的

如果您不想搜索整个集合或不想从头开始搜索,请使用。

返回:

类型 说明
Number 在集合中找到的第一个匹配项的位置,如果没有匹配项,则为 -1。

例子:

// index is the index of the first graphic in the
// graphics layer that matches the input graphic
let index = graphicsLayer.graphics.indexOf(graphic);

相关用法


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