TimeInfo 提供诸如存储每个要素的 start 和 end 时间以及该图层的 fullTimeExtent 的日期字段等信息。如果为 GeoJSONLayer 设置
timeInfo
属性及其startField
和endField
属性,则必须在层初始化时进行设置。加载图层后,timeInfo 参数无法更改。timeInfo
的fullTimeExtent 是根据其startField
和endField
属性自动计算的。如果日期信息存储在纪元/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
用法说明
GeoJSONLayer.timeInfo
函数(或属性)的定义如下:
相关用法
- JavaScript ArcGIS GeoJSONLayer.timeOffset用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.timeExtent用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.minScale用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.url用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.createQuery用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.queryFeatureCount用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.orderBy用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.applyEdits用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.maxScale用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.labelingInfo用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.fullExtent用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.refresh用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.featureEffect用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.fields用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.queryFeatures用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.opacity用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.visible用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.when用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.featureReduction用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.on用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.effect用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.queryObjectIds用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.outFields用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.queryExtent用法及代码示例
- JavaScript ArcGIS GeoJSONLayer.spatialReference用法及代码示例
注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 GeoJSONLayer.timeInfo。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。