TimeInfo 提供诸如存储每个要素的start 和end 时间以及图层的fullTimeExtent 的日期字段等信息。如果要为 GeoJSONLayer 设置
timeInfo
属性及其startField
和endField
属性,则必须在层初始化时设置。图层为 loaded 后,timeInfo 参数无法更改。timeInfo
的 fullTimeExtent 是根据其startField
和endField
属性自动计算的。如果日期信息存储在 epoch/unix 时间戳中,则在图层初始化时创建日期字段。如果日期信息未存储在纪元/unix 时间戳中,则必须将它们转换为纪元时间戳,以便可以为图层创建日期字段。以下代码片段显示了如何根据 ISO-8601 字符串在 GeoJSONLayer 中创建日期字段。// intercept the geojson data after it is fetched so that we can parse // the ISO-8601 string values to epoch timestamp before the GeoJSONLayer is created. esriConfig.request.interceptors.push({ urls: geojsonUrl, after: function(response) { if (response.url?.valueOf().toLowerCase().includes("earthquakes")) { const geojson = response.data; geojson.features.forEach((feature) => { const unixDate = Date.parse(feature.properties.isoDate); feature.properties.unixDate = unixDate; }); } } }); // create a time aware GeoJSONLayer by setting its timeInfo property in // the constructor. We must also set the fields parameter in the layer // constructor to indicate that the unixDate field is a date field. // in this case, unixDate must contain unix timestamp. const layer = new GeoJSONLayer({ url: geojsonUrl, popupTemplate: { title: "{name}", content: "ISO date: {isoDate} <br> Unix date: {unixDate}" }, fields: [ { "name": "unixDate", "alias": "unixDate", "type": "date" } ], timeInfo: { startField: "unixDate", interval: { unit: "years", value: 1 } } });
默认值:null
例子:
// create geojson layer from usgs earthquakes geojson feed const geojsonLayer = new GeoJSONLayer({ url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", copyright: "USGS Earthquakes", fields: [ { "name": "mag", "type": "double" }, { "name": "place", "type": "string" }, { "name": "time", "type": "date" }, // date field { "name": "depth", "type": "double" } ], // timeInfo can be used to do temporal queries // set the startField and endField. // timeExtent is automatically calculated from the start and end date fields // The date values must be in milliseconds number from the UNIX epoch specified in UTC. timeInfo: { startField: "time" } });
基本信息
以下是所在类或对象的基本信息。
AMD:
require(["esri/layers/GeoJSONLayer"], (GeoJSONLayer) => { /* code goes here */ });
ESM:
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer";
类:
esri/layers/GeoJSONLayer
继承: GeoJSONLayer > Layer > Accessor
自从:用于 JavaScript 4.11 的 ArcGIS API
用法说明
esri/layers/GeoJSONLayer.timeInfo
函数(或属性)的定义如下:
相关用法
- JavaScript esri/layers/GeoJSONLayer.timeExtent用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.timeOffset用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.effect用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.refresh用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.applyEdits用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.visible用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.featureReduction用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.orderBy用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.customParameters用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.maxScale用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.useViewTime用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.queryFeatureCount用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.queryObjectIds用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.capabilities用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.queryExtent用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.outFields用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.url用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.fullExtent用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.createQuery用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.labelingInfo用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.opacity用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.featureEffect用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.fields用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.when用法及代码示例
- JavaScript esri/layers/GeoJSONLayer.minScale用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 esri/layers/GeoJSONLayer.timeInfo。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。