UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

948 lines (945 loc) • 94.9 kB
import type PopupTemplate from "../PopupTemplate.js"; import type Extent from "../geometry/Extent.js"; import type SpatialReference from "../geometry/SpatialReference.js"; import type Layer from "./Layer.js"; import type FeatureTemplate from "./support/FeatureTemplate.js"; import type Field from "./support/Field.js"; import type FieldsIndex from "./support/FieldsIndex.js"; import type LabelClass from "./support/LabelClass.js"; import type TimeInfo from "./support/TimeInfo.js"; import type PortalItem from "../portal/PortalItem.js"; import type AttributeBinsFeatureSet from "../rest/support/AttributeBinsFeatureSet.js"; import type FeatureSet from "../rest/support/FeatureSet.js"; import type Query from "../rest/support/Query.js"; import type ElevationInfo from "../symbols/support/ElevationInfo.js"; import type AttributeTableTemplate from "../tables/AttributeTableTemplate.js"; import type TimeExtent from "../time/TimeExtent.js"; import type TimeInterval from "../time/TimeInterval.js"; import type { MultiOriginJSONSupportMixin } from "../core/MultiOriginJSONSupport.js"; import type { Edits, EditsResult } from "../editing/types.js"; import type { LayerEvents, LayerProperties } from "./Layer.js"; import type { FeatureLayerCapabilities, FieldDomainOptions } from "./types.js"; import type { BlendLayer, BlendLayerProperties } from "./mixins/BlendLayer.js"; import type { CustomParameters, CustomParametersMixin, CustomParametersMixinProperties } from "./mixins/CustomParametersMixin.js"; import type { DisplayFilteredLayer, DisplayFilteredLayerProperties } from "./mixins/DisplayFilteredLayer.js"; import type { EditBusLayerEvents } from "./mixins/EditBusLayer.js"; import type { FeatureEffectLayer, FeatureEffectLayerProperties } from "./mixins/FeatureEffectLayer.js"; import type { FeatureReductionLayer, FeatureReductionLayerProperties } from "./mixins/FeatureReductionLayer.js"; import type { OperationalLayer, OperationalLayerProperties } from "./mixins/OperationalLayer.js"; import type { OrderedLayer, OrderedLayerProperties } from "./mixins/OrderedLayer.js"; import type { PortalLayer, PortalLayerProperties } from "./mixins/PortalLayer.js"; import type { RefreshableLayerEvents, RefreshableLayer, RefreshableLayerProperties } from "./mixins/RefreshableLayer.js"; import type { ScaleRangeLayer, ScaleRangeLayerProperties } from "./mixins/ScaleRangeLayer.js"; import type { TemporalLayer, TemporalLayerProperties } from "./mixins/TemporalLayer.js"; import type { TrackableLayer, TrackableLayerProperties } from "./mixins/TrackableLayer.js"; import type { TimeInfoProperties } from "./support/TimeInfo.js"; import type { DomainUnion } from "./support/types.js"; import type { PortalItemProperties } from "../portal/PortalItem.js"; import type { RendererUnion } from "../renderers/types.js"; import type { RequestOptions } from "../request/types.js"; import type { AttributeBinsQueryProperties } from "../rest/support/AttributeBinsQuery.js"; import type { QueryProperties } from "../rest/support/Query.js"; import type { CreatePopupTemplateOptions } from "../support/popupUtils.js"; import type { TimeZone } from "../time/types.js"; import type { ObjectId } from "../views/types.js"; import type { TimeExtentProperties } from "../time/TimeExtent.js"; import type { TimeIntervalProperties } from "../time/TimeInterval.js"; import type { AttributeTableTemplateProperties } from "../tables/AttributeTableTemplate.js"; import type { ElevationInfoProperties } from "../symbols/support/ElevationInfo.js"; import type { FieldProperties } from "./support/Field.js"; import type { ExtentProperties } from "../geometry/Extent.js"; import type { LabelClassProperties } from "./support/LabelClass.js"; import type { PopupTemplateProperties } from "../PopupTemplate.js"; import type { HeatmapRendererProperties } from "../renderers/HeatmapRenderer.js"; import type { PieChartRendererProperties } from "../renderers/PieChartRenderer.js"; import type { DictionaryRendererProperties } from "../renderers/DictionaryRenderer.js"; import type { DotDensityRendererProperties } from "../renderers/DotDensityRenderer.js"; import type { UniqueValueRendererProperties } from "../renderers/UniqueValueRenderer.js"; import type { ClassBreaksRendererProperties } from "../renderers/ClassBreaksRenderer.js"; import type { SimpleRendererProperties } from "../renderers/SimpleRenderer.js"; import type { SpatialReferenceProperties } from "../geometry/SpatialReference.js"; import type { FeatureTemplateProperties } from "./support/FeatureTemplate.js"; export interface GeoJSONLayerProperties extends LayerProperties, PortalLayerProperties, OperationalLayerProperties, RefreshableLayerProperties, ScaleRangeLayerProperties, TrackableLayerProperties, TemporalLayerProperties, BlendLayerProperties, FeatureEffectLayerProperties, FeatureReductionLayerProperties, CustomParametersMixinProperties, DisplayFilteredLayerProperties, OrderedLayerProperties, Partial<Pick<GeoJSONLayer, "copyright" | "definitionExpression" | "displayField" | "editingEnabled" | "geometryType" | "labelsVisible" | "legendEnabled" | "objectIdField" | "outFields" | "popupEnabled" | "screenSizePerspectiveEnabled" | "url">> { /** * This property is used to configure the associated layer's [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/). It is meant to configure how the columns display within the table in regard to visibility, column order, and sorting. * * > [!WARNING] * > * > This property differs from the [FeatureTable's tableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) property. The `TableTemplate` provides more fine-grained control over how the table is rendered within the application by offering more advanced configurations such as custom cell rendering, column formatting, and more. `TableTemplate` is useful for application-level development that remains within an application. Use the `attributeTableTemplate` property to access the table's settings across different applications. By using this property, the settings can be saved within a webmap or layer. Please refer to the [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) and [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) documentation for more information. * * @since 4.31 */ attributeTableTemplate?: AttributeTableTemplateProperties | null; /** * A list of custom parameters appended to the URL of all resources fetched by the layer. * It's an object with key-value pairs where value is a string. * The layer's `refresh()` method needs to be called if the customParameters are updated at runtime. * * @since 4.22 * @see [Sample - GeoJSONLayer with dynamic URL](https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson-refresh/) * @example * // set customParameters to request the top 3 earthquakes since 1900. * // The USGS earthquakes catalog returns earthquakes with specified query parameters. * const geojsonLayer = new GeoJSONLayer({ * url: "https://earthquake.usgs.gov/fdsnws/event/1/query", * customParameters: { * format: "geojson", * starttime: "1900-01-01", * endtime: "2021-01-01", * minmagnitude: "8", * orderby:"magnitude", * limit: "3" * } * }); * @example * // send a custom parameter to your special service * let layer = new MapImageLayer({ * url: serviceUrl, * customParameters: { * "key": "my-special-key" * } * }); */ customParameters?: CustomParameters | null; /** * Specifies how features are placed on the vertical axis (z). This property may only be used * in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/) * for an example of how this property may be used. * * > [!WARNING] * > * > If the elevation info is not specified, the effective elevation depends on the context and could vary per graphic. */ elevationInfo?: ElevationInfoProperties | null; /** * An array of fields in the layer. * * @example * // define each field's schema * let fields = [ * new Field({ * "name": "ObjectID", * "alias": "ObjectID", * "type": "oid" * }), new Field({ * "name": "description", * "alias": "Description", * "type": "string" * }), new Field ({ * "name": "title", * "alias": "Title", * "type": "string" * }) * ]; */ fields?: FieldProperties[]; /** * The full extent of the layer. * * @example * // Once the layer loads, set the view's extent to the layer's full extent * layer.when(function(){ * view.extent = layer.fullExtent; * }); */ fullExtent?: ExtentProperties | null; /** * The label definition for this layer, specified as an array of * [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/). Use this property to specify * labeling properties for the layer such as label expression, placement, and size. * * Multiple Label classes with different `where` clauses can be used to define several * labels with varying styles on the same feature. Likewise, multiple label classes * may be used to label different types of features (for example blue labels * for lakes and green labels for parks). * * > [!WARNING] * > * > **Known Limitations** * > * > 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) only support displaying one [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) per feature. * * @see [Sample: Add multiple label classes to a layer](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiple-classes/) * @see [Sample: Multi-line labels](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiline/) * @see [Sample: Flat vs. volumetric 3D symbol layers](https://developers.arcgis.com/javascript/latest/sample-code/symbols-points-3d/) * @example * const statesLabelClass = new LabelClass({ * labelExpressionInfo: { expression: "$feature.NAME" }, * symbol: { * type: "text", // autocasts as new TextSymbol() * color: "black", * haloSize: 1, * haloColor: "white" * } * }); * geoJSONLayer.labelingInfo = [ statesLabelClass ]; */ labelingInfo?: LabelClassProperties[] | null; /** * The popup template for the layer. When set on the layer, the `popupTemplate` * allows users to access attributes and display their values in the * view's Popup when a feature is selected * using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/) * for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) interacts with a * [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/). * * A default popup template is automatically used if no `popupTemplate` has been defined when * [Popup.defaultPopupTemplateEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/#defaultPopupTemplateEnabled) * is set to `true`. * * @see [createPopupTemplate()](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#createPopupTemplate) * @see [SceneView.popup](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#popup) * @see [View2D.popup](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/#popup) */ popupTemplate?: PopupTemplateProperties | null; /** * The portal item referencing the geojson file from which the GeoJSONLayer is loaded. * * @since 4.25 * @example * // Initialize GeoJSONLayer by referencing a portalItem id pointing to geojson file. * const layer = new GeoJSONLayer({ * portalItem: { // autocasts as new PortalItem() * id: "81e769cd7031482797e1b0768f23c7e1" * } * }); * @example * // Initialize GeoJSONLayer by referencing a portalItem id pointing to geojson file. * const layer = new GeoJSONLayer({ * portalItem: new PortalItem({ * id: "81e769cd7031482797e1b0768f23c7e1", * // optionally define the portal, of the item. * // if not specified, the default portal defined is used. * // see https://developers.arcgis.com/javascript/latest/references/core/config/#portalUrl * portal: new Portal({ * url: "https://jsapi.maps.arcgis.com/" * }) * } * }); * @example * // While this example uses FeatureLayer, this same pattern can be * // used for other layers that may be loaded from portalItem ids. * const layer = new FeatureLayer({ * portalItem: { // autocasts as new PortalItem() * id: "caa9bd9da1f4487cb4989824053bb847" * } // the first layer in the service is returned * }); * @example * // Set hostname when using an on-premise portal (default is ArcGIS Online) * // esriConfig.portalUrl = "http://myHostName.esri.com/arcgis"; * * // While this example uses FeatureLayer, this same pattern can be * // used for SceneLayers. * const layer = new FeatureLayer({ * portalItem: { // autocasts as new PortalItem() * id: "8d26f04f31f642b6828b7023b84c2188" * }, * // loads the third item in the given feature service * layerId: 2 * }); * @example * // Initialize GeoJSONLayer by referencing a portalItem id pointing to geojson file. * const layer = new GeoJSONLayer({ * portalItem: new PortalItem({ * id: "81e769cd7031482797e1b0768f23c7e1", * // optionally define the portal, of the item. * // if not specified, the default portal defined is used. * // see https://developers.arcgis.com/javascript/latest/references/core/config/#portalUrl * portal: new Portal({ * url: "https://jsapi.maps.arcgis.com/" * }) * } * }); * @example * // This snippet loads a table hosted in ArcGIS Online. * const table = new FeatureLayer({ * portalItem: { // autocasts as esri/portal/PortalItem * id: "123f4410054b43d7a0bacc1533ceb8dc" * } * }); * * // Before adding the table to the map, it must first be loaded and confirm it is the right type. * table.load().then(() => { * if (table.isTable) { * map.tables.add(table); * } * }); * @example * // While this example uses FeatureLayer, this same pattern can be * // used for other layers that may be loaded from portalItem ids. * const layer = new FeatureLayer({ * portalItem: { // autocasts as esri/portal/PortalItem * id: "caa9bd9da1f4487cb4989824053bb847", * // Set an API key to access a secure portal item configured with API key authentication. * apiKey: "APIKEY" * } * }); */ portalItem?: PortalItemProperties | null; /** * Refresh interval of the layer in minutes. Value of `0` indicates no refresh. * * @default 0 * @since 4.22 * @see [refresh()](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#refresh) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#event-refresh) * @see [Sample - GeoJSONLayer with dynamic URL](https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson-refresh/) * @example * // the layer will be refreshed every 1 minute. * layer.refreshInterval = 1; * @see [RefreshableLayer.refresh()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#refresh) * @see [refresh event](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/RefreshableLayer/#event-refresh) * @example * // the layer will be refreshed every minute. * layer.refreshInterval = 1; */ refreshInterval?: number; /** * The renderer assigned to the layer. The renderer defines how to * visualize each feature in the layer. Depending on the renderer type, * features may be visualized with the same symbol, or with varying symbols * based on the values of provided attribute fields or functions. If not specified, * a default renderer will be generated based on the geometry type. * * @see [Styles and data visualization](https://developers.arcgis.com/javascript/latest/visualization/) */ renderer?: (((SimpleRendererProperties & { type: "simple" }) | (ClassBreaksRendererProperties & { type: "class-breaks" }) | (UniqueValueRendererProperties & { type: "unique-value" }) | (DotDensityRendererProperties & { type: "dot-density" }) | (DictionaryRendererProperties & { type: "dictionary" }) | (PieChartRendererProperties & { type: "pie-chart" })) | (HeatmapRendererProperties & { type: "heatmap" })) | null; /** * The spatial reference of the layer. The default value is WGS84. * This property can be set explicitly to project the longitude and latitude * coordinates when the layer parses the GeoJSON file. While not required, explicitly setting * the spatial reference of the layer will improve the performance * when projecting to a spatial reference other than the one used by the * coordinates in the raw data. * * @default SpatialReference.WGS84 * @see [SpatialReference.WGS84](https://developers.arcgis.com/javascript/latest/references/core/geometry/SpatialReference/#WGS84) * @example * const geoJSONLayer = new GeoJSONLayer({ * url: "example.geojson", * spatialReference: { * wkid: 5936 * } * }); */ spatialReference?: SpatialReferenceProperties; /** * An array of feature templates defined in the layer. * See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/an-overview-of-subtypes.htm). */ templates?: FeatureTemplateProperties[] | null; /** * The layer's time extent. When the layer's [useViewTime](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#useViewTime) is `false`, the layer * instructs the view to show data from the layer based on this time extent. * If the `useViewTime` is `true`, and both layer and view time extents are set, then features that fall within * the intersection of the view and layer time extents will be displayed. * For example, if the layer's time extent is set to display features between 1970 and 1975 and * the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975. * * @since 4.14 * @example * if (!layer.useViewTime) { * if (layer.timeExtent) { * console.log("Current timeExtent:", layer.timeExtent.start, " - ", layer.timeExtent.end} * } else { * console.log("The layer will display data within the view's timeExtent."); * console.log("Current view.timeExtent:", view.timeExtent.start, " - ", view.timeExtent.end} * } * } * @example * // set the timeExtent on the layer and useViewTime false * // In this case, the layer will honor its timeExtent and ignore * // the view's timeExtent * const layer = new ImageryLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ScientificData/SeaTemperature/ImageServer", * timeExtent: { * start: new Date(2014, 4, 18), * end: new Date(2014, 4, 19) * }, * useViewTime: false * }); * @example * // timeExtent is set on the layer and the view * // In this case, the layer will display features that fall * // within the intersection of view and layer time extents * // features within Jan 1, 1976 - Jan 1, 1981 will be displayed * const view = new MapView({ * timeExtent: { * start: new Date(1976, 0, 1), * end: new Date(2002, 0, 1) * } * }); * const layer = new FeatureLayer({ * url: myUrl, * timeExtent: { * start: new Date(1974, 0, 1), * end: new Date(1981, 0, 1) * } * }); * @example * if (!layer.useViewTime) { * if (layer.timeExtent) { * console.log("Current timeExtent:", layer.timeExtent.start, " - ", layer.timeExtent.end} * } else { * console.log("The layer will display data within the view's timeExtent."); * console.log("Current view.timeExtent:", view.timeExtent.start, " - ", view.timeExtent.end} * } * } * @example * // set the timeExtent on the layer and useViewTime false * // In this case, the layer will honor its timeExtent and ignore * // the view's timeExtent * const layer = new ImageryLayer({ * url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ScientificData/SeaTemperature/ImageServer", * timeExtent: { * start: new Date(2014, 4, 18), * end: new Date(2014, 4, 19) * }, * useViewTime: false * }); * @example * // timeExtent is set on the layer and the view * // In this case, the layer will display features that fall * // within the intersection of view and layer time extents * // features within Jan 1, 1976 - Jan 1, 1981 will be displayed * const view = new MapView({ * timeExtent: { * start: new Date(1976, 0, 1), * end: new Date(2002, 0, 1) * } * }); * const layer = new FeatureLayer({ * url: myUrl, * timeExtent: { * start: new Date(1974, 0, 1), * end: new Date(1981, 0, 1) * } * }); */ timeExtent?: TimeExtentProperties | null; /** * TimeInfo provides information such as date fields that store [start](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#startField) * and [end](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#endField) time * for each feature and the [TimeInfo.fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#fullTimeExtent) * for the layer. The `timeInfo` property, along with its `startField` and `endField` properties, must be set at the * time of layer initialization if it is being set for a [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/). * The timeInfo parameters cannot be changed after the layer is [loaded](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#loaded). * The [TimeInfo.fullTimeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/support/TimeInfo/#fullTimeExtent) for `timeInfo` is * automatically calculated based on its `startField` and `endField` properties. * * @since 4.11 * @example * // 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. * // 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" * } * }); * @example * // 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 * // the start and end date fields * // The date values must be in milliseconds number from the UNIX epoch specified in UTC. * timeInfo: { * startField: "time" * } * }); */ timeInfo?: TimeInfoProperties | null; /** * A temporary offset of the time data based on a certain [TimeInterval](https://developers.arcgis.com/javascript/latest/references/core/time/TimeInterval/). This allows * users to overlay features from two or more time-aware layers with different time extents. * For example, if a layer has data recorded for the year 1970, an offset value of 2 years would temporarily shift the data to * 1972. You can then overlay this data with data recorded in 1972. * A time offset can be used for display purposes only. The query and selection are not affected by the offset. * * @since 4.14 * @example * // Offset a geojson Layer containing hurricanes from 2015 so that they appear in 2019 (+4 years). * let layer = new GeoJSONLayer({ * url: `hurricanes-and-storms-2015.geojson`, * timeOffset: { * value: 4, * unit: "years" * }, * timeInfo: { * startField: "ISO_time" * }, * renderer: { * type: "simple", * symbol: { * type: "simple-marker", * size: 6, * color: "red", * outline: { * width: 0.5, * color: "black" * } * } * } * }); * @example * // Offset a CSV Layer containing hurricanes from 2015 so that they appear in 2019 (+4 years). * let layer = new CSVLayer({ * url: `hurricanes-and-storms-2015.csv`, * timeOffset: { * value: 4, * unit: "years" * }, * timeInfo: { * startField: "ISO_time" * }, * renderer: { * type: "simple", * symbol: { * type: "simple-marker", * size: 6, * color: "red", * outline: { * width: 0.5, * color: "black" * } * } * } * }); */ timeOffset?: TimeIntervalProperties | null; /** * The title of the layer used to identify it in places such as the [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/) * and [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/). * * @default "GeoJSON" */ title?: string | null; /** * Determines if the layer will update its temporal data based on the view's * [View.timeExtent](https://developers.arcgis.com/javascript/latest/references/core/views/View/#timeExtent). When `false`, the layer will display its temporal * data based on the layer's [timeExtent](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#timeExtent), regardless of changes to the view. * If both view and layer time extents are set while this property is `true`, then the features that fall within * the intersection of the view and layer time extents will be displayed. * For example, if a layer's time extent is set to display features between 1970 and 1975 and * the view has a time extent set to 1972-1980, the effective time on the feature layer will be 1972-1975. * * @default true * @since 4.14 * @example * if (featureLayer.useViewTime) { * console.log("Displaying data between:", view.timeExtent.start, " - ", view.timeExtent.end); * } * @example * if (featureLayer.useViewTime) { * console.log("Displaying data between:", view.timeExtent.start, " - ", view.timeExtent.end); * } */ useViewTime?: boolean; } export interface GeoJSONLayerEvents extends EditBusLayerEvents, RefreshableLayerEvents, LayerEvents {} /** * * [Overview](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#overview) * * [Creating a GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#creating-a-geojsonlayer) * * [Notes](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#limits) * * <span id="overview"></span> * ## Overview * The GeoJSONLayer class is used to create a layer based on [GeoJSON](https://geojson.org/). * GeoJSON is a format for encoding a variety of geographic data structures. * The GeoJSON data must comply with the [RFC 7946 specification](https://tools.ietf.org/html/rfc7946) which states * that the coordinates are in [SpatialReference.WGS84](https://developers.arcgis.com/javascript/latest/references/core/geometry/SpatialReference/#WGS84). * Refer to FeatureLayer's [querying your data](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#querying) section to learn more about how to query your geojson data, and * the [data visualization](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#data-visualization) section to learn how to change the GeoJSONLayer's visualization. * * Please see the table below for supported geometry objects from GeoJSON and their corresponding geometry types: * GeoJSON Geometry Object | API Geometry Type | * ------------------------|-------------------| * Point | [Point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/) | * MultiPoint | [Multipoint](https://developers.arcgis.com/javascript/latest/references/core/geometry/Multipoint/) | * LineString/MultiLineString | [Polyline](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polyline/) | * Polygon/MultiPolygon | [Polygon](https://developers.arcgis.com/javascript/latest/references/core/geometry/Polygon/) | * * <span id="creating-a-geojsonlayer"></span> * ## Creating a GeoJSONLayer * * GeoJSONLayer is created by setting its [url](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#url) property to point to geojson feed or to a blob url for in memory geojson data. * * ### Reference a geojson feed URL * * To create a GeoJSONLayer instance from a geojson feed, you must set the [url](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#url) property * to the url of the geojson feed. * * ```js * const GeoJSONLayer = await $arcgis.import("@arcgis/core/layers/GeoJSONLayer.js"); * // points to the states layer in a service storing U.S. census data * const geojsonlayer = new GeoJSONLayer({ * url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", * copyright: "USGS Earthquakes" * }); * map.add(geojsonlayer); // adds the layer to the map * ``` * * ### Reference in memory geojson data by a blob url * * You can also create a GeoJSONLayer from in memory geojson data by passing a [blob url](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) to the * [url](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#url) property of the layer. The following snippet shows how to create a new GeoJSONLayer from a blob url. * ```js * // create a geojson layer from geojson feature collection * const geojson = { * type: "FeatureCollection", * features: [ * { * type: "Feature", * id: 1, * geometry: { * type: "Polygon", * coordinates: [ * [ * [100.0, 0.0], * [101.0, 0.0], * [101.0, 1.0], * [100.0, 1.0], * [100.0, 0.0] * ] * ] * }, * properties: { * type: "single", * recordedDate: "2018-02-07T22:45:00-08:00" * } * } * ] * }; * * // create a new blob from geojson featurecollection * const blob = new Blob([JSON.stringify(geojson)], { * type: "application/json" * }); * * // URL reference to the blob * const url = URL.createObjectURL(blob); * // create new geojson layer using the blob url * const layer = new GeoJSONLayer({ * url * }); * ``` * * > [!WARNING] * > * > <span id="limits"></span> * > **Notes** * > * > Each GeoJSONLayer will only accept one geometry type. If there are multiple types of geometries, * > only the type specified in [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#geometryType) will be loaded. If [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#geometryType) * > is not specified, it will default to the geometry type of the first geometry. * > Each GeoJSONLayer will only accept one schema of the properties. The [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#fields) property * > can be used to specify the desired fields for the layer. If [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#fields) is not defined, the schema used by * > the first feature will be used to deduce the fields schema for the layer. * > [GeometryCollection](https://tools.ietf.org/html/rfc7946#section-3.1.8) is not supported. * > Using Object as attribute value for GeoJSON features is not supported. * > Geometries that cross the Antimeridian line are not currently supported. * > Date [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#fields) will be created implicitly when GeoJSONLayer is loaded, if the geojson [feature](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2) objects * > have properties containing date and time values such as ISO8601 date strings. * * @since 4.11 * @see [Sample - Add GeoJSONLayer to your Map](https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson/) * @see [Sample - Filter features with TimeSlider](https://developers.arcgis.com/javascript/latest/sample-code/timeslider-component-filter/) * @see [Sample - GeoJSONLayer with dynamic URL](https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson-refresh/) * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/) * @see [GeoJSONLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/GeoJSONLayerView/) * @see [Querying your data](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#querying) * @see [Data Visualization](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#data-visualization) */ export default class GeoJSONLayer extends GeoJSONLayerSuperclass { /** * @deprecated * Do not directly reference this property. * Use EventNames and EventTypes helpers from \@arcgis/core/Evented */ "@eventTypes": GeoJSONLayerEvents; /** * @example * const geoJSONLayer = new GeoJSONLayer({ * url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", * copyright: "USGS Earthquakes", * }); * map.add(geoJSONLayer); // adds the layer to the map */ constructor(properties?: GeoJSONLayerProperties); /** * This property is used to configure the associated layer's [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/). It is meant to configure how the columns display within the table in regard to visibility, column order, and sorting. * * > [!WARNING] * > * > This property differs from the [FeatureTable's tableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) property. The `TableTemplate` provides more fine-grained control over how the table is rendered within the application by offering more advanced configurations such as custom cell rendering, column formatting, and more. `TableTemplate` is useful for application-level development that remains within an application. Use the `attributeTableTemplate` property to access the table's settings across different applications. By using this property, the settings can be saved within a webmap or layer. Please refer to the [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) and [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) documentation for more information. * * @since 4.31 */ get attributeTableTemplate(): AttributeTableTemplate | null | undefined; set attributeTableTemplate(value: AttributeTableTemplateProperties | null | undefined); /** * Describes the layer's supported capabilities. * * @example * // Once the layer loads, check if the supportsStatistics operations is enabled on the layer * await layer.load(); * if (layer.capabilities.query.supportsStatistics) { * // query for the sum of the population in all features * let sumPopulation = { * onStatisticField: "POP_2015", // service field for 2015 population * outStatisticFieldName: "Pop_2015_sum", * statisticType: "sum" * } * let query = layer.createQuery(); * query.outStatistics = [ sumPopulation ]; * const result = await layer.queryFeatures(query); * // process the stats query result * } */ get capabilities(): FeatureLayerCapabilities; /** Copyright information for the layer. */ accessor copyright: string | null | undefined; /** * A list of custom parameters appended to the URL of all resources fetched by the layer. * It's an object with key-value pairs where value is a string. * The layer's `refresh()` method needs to be called if the customParameters are updated at runtime. * * @since 4.22 * @see [Sample - GeoJSONLayer with dynamic URL](https://developers.arcgis.com/javascript/latest/sample-code/layers-geojson-refresh/) * @example * // set customParameters to request the top 3 earthquakes since 1900. * // The USGS earthquakes catalog returns earthquakes with specified query parameters. * const geojsonLayer = new GeoJSONLayer({ * url: "https://earthquake.usgs.gov/fdsnws/event/1/query", * customParameters: { * format: "geojson", * starttime: "1900-01-01", * endtime: "2021-01-01", * minmagnitude: "8", * orderby:"magnitude", * limit: "3" * } * }); * @example * // send a custom parameter to your special service * let layer = new MapImageLayer({ * url: serviceUrl, * customParameters: { * "key": "my-special-key" * } * }); */ accessor customParameters: CustomParameters | null | undefined; /** * The time zone that dates are stored in. Time zone is always `UTC` for GeoJSONLayer. * This property may be useful when constructing date or time [where clauses](https://developers.arcgis.com/javascript/latest/references/core/rest/support/Query/#date-query). * * @since 4.28 */ get dateFieldsTimeZone(): TimeZone | null | undefined; /** * The SQL where clause used to filter features on the client. Only the features that satisfy the definition * expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/). * Definition expressions may be set when a layer is constructed prior to it loading in the view or * after it has been added to the map. If the definition expression is set after the layer has been added to the map, the view will * automatically refresh itself to display the features that satisfy the new definition expression. * * @example * // Set definition expression in constructor to only display earthquakes magnitude 5.0 and greater * const layer = new GeoJSONLayer({ * url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson", * definitionExpression: "mag >= 5" * }); * @example * // Set the definition expression directly on layer instance after it has loaded * layer.definitionExpression = "mag >= 5"; */ accessor definitionExpression: string | null | undefined; /** The name of the layer's primary display field. The value of this property matches the name of one of the fields of the layer. */ accessor displayField: string | null | undefined; /** * Indicates if the layer is editable. The GeoJSONLayer features are only editable in memory. The source geojson file is not modified when editing features. * Therefore `editingEnabled` is `false` by default. If set to `true`, the source geojson file needs to be updated manually. * * @default false * @since 4.22 * @see [applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#applyEdits) */ accessor editingEnabled: boolean; /** * Specifies how features are placed on the vertical axis (z). This property may only be used * in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/) * for an example of how this property may be used. * * > [!WARNING] * > * > If the elevation info is not specified, the effective elevation depends on the context and could vary per graphic. */ get elevationInfo(): ElevationInfo | null | undefined; set elevationInfo(value: ElevationInfoProperties | null | undefined); /** * An array of fields in the layer. * * @example * // define each field's schema * let fields = [ * new Field({ * "name": "ObjectID", * "alias": "ObjectID", * "type": "oid" * }), new Field({ * "name": "description", * "alias": "Description", * "type": "string" * }), new Field ({ * "name": "title", * "alias": "Title", * "type": "string" * }) * ]; */ get fields(): Field[]; set fields(value: FieldProperties[]); /** * A convenient property that can be used to make case-insensitive lookups for a field by name. * It can also provide a list of the [date fields](https://developers.arcgis.com/javascript/latest/references/core/layers/support/FieldsIndex/#dateFields) in a layer. * * @since 4.12 * @example * // lookup a field by name. name is case-insensitive * const field = layer.fieldsIndex.get("SoMeFiEld"); * * if (field) { * console.log(field.name); // SomeField * } */ get fieldsIndex(): FieldsIndex<Field>; /** * The full extent of the layer. * * @example * // Once the layer loads, set the view's extent to the layer's full extent * layer.when(function(){ * view.extent = layer.fullExtent; * }); */ get fullExtent(): Extent | null | undefined; set fullExtent(value: ExtentProperties | null | undefined); /** * The geometry type of features in the layer. All features must be of the same type. * The GeoJSONLayer can consume GeoJSON feature collections with mixed geometries * and will only read the features with the specified geometry type if `geometryType` is set, otherwise the geometry type * is determined from the first feature with a geometry. The geometry type is `null` if [isTable](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#isTable) is `true`. */ accessor geometryType: "point" | "polygon" | "polyline" | "multipoint" | null | undefined; /** * Indicates whether the client-side features in the layer have `Z` (elevation) values. * Refer to [elevationInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#elevationInfo) for details regarding placement and rendering * of features with z-values in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * Use the `supportsZ` property in the layer's [capabilities.data](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#capabilities) * object to verify if `Z` values are supported on the features. */ get hasZ(): boolean; /** * Returns `true` if the layer is loaded from a non-spatial table in a service. Non-spatial geojson tables do not have * geometry object that represent geographic features. The [geometryType](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#geometryType) of the layer will be `null` if the `isTable` is true. * * Non-spatial table instance can be created from the [url](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#url) and the table must be loaded by calling [load()](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#load) method. * * @default false * @since 4.24 * @see [Map.tables](https://developers.arcgis.com/javascript/latest/references/core/Map/#tables) * @see [WebMap.tables](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#tables) * @see [Map.allTables](https://developers.arcgis.com/javascript/latest/references/core/Map/#allTables) * @see [WebMap.allTables](https://developers.arcgis.com/javascript/latest/references/core/WebMap/#allTables) */ get isTable(): boolean; /** * The label definition for this layer, specified as an array of * [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/). Use this property to specify * labeling properties for the layer such as label expression, placement, and size. * * Multiple Label classes with different `where` clauses can be used to define several * labels with varying styles on the same feature. Likewise, multiple label classes * may be used to label different types of features (for example blue labels * for lakes and green labels for parks). * * > [!WARNING] * > * > **Known Limitations** * > * > 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) only support displaying one [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) per feature. * * @see [Sample: Add multiple label classes to a layer](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiple-classes/) * @see [Sample: Multi-line labels](https://developers.arcgis.com/javascript/latest/sample-code/labels-multiline/) * @see [Sample: Flat vs. volumetric 3D symbol layers](https://developers.arcgis.com/javascript/latest/sample-code/symbols-points-3d/) * @example * const statesLabelClass = new LabelClass({ * labelExpressionInfo: { expression: "$feature.NAME" }, * symbol: { * type: "text", // autocasts as new TextSymbol() * color: "black", * haloSize: 1, * haloColor: "white" * } * }); * geoJSONLayer.labelingInfo = [ statesLabelClass ]; */ get labelingInfo(): LabelClass[] | null | undefined; set labelingInfo(value: LabelClassProperties[] | null | undefined); /** * Indicates whether to display labels for this layer. If `true`, labels will * appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#labelingInfo) property. * * > [!WARNING] * > * > **Known Limitations** * > * > 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) only support displaying one [LabelClass](https://developers.arcgis.com/javascript/latest/references/core/layers/support/LabelClass/) per feature. * * @default true */ accessor labelsVisible: boolean; /** * Indicates whether the layer will be included in the legend. * * @default true */ accessor legendEnabled: boolean; /** * The name of a [field](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#fields) containing a unique value or identifier for each feature in the layer. * if the feature `id` is present in the GeoJSON, it will be used as the `oid` field. Starting at version 4.22, this field will be a type of an `oid` field * if the feature `id` is an integer, or will be a `string` field if the feature `id` is a string. * If the feature `id` property is not present and `objectIDField` is not specified, `__ObjectID` field will be generated for each feature * starting from 1. * * @since 4.15 * @see [fields](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#fields) */ accessor objectIdField: string; /** * An array of field names from the geoJSON file to include with each feature. * To fetch the values from all fields in the layer, use `["*"]`. * The required fields used for layer [rendering](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#renderer), [labeling](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#labelingInfo), and * setting the [elevation info](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/#elevationInfo), along with the fields specified in `outFields` are used to populate * [FeatureLikeLayerView.availableFields](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLikeLayerView/#availableField