Skip to content
import ElevationSampler from "@arcgis/core/layers/support/ElevationSampler.js";
Inheritance:
ElevationSamplerAccessor
Since
ArcGIS Maps SDK for JavaScript 4.7

A cache of elevation values created from an elevation service or the GroundView used for synchronously querying elevation information for geometries. This class does not have a constructor. You can create an instance of this class by using ElevationLayer.createElevationSampler() or Ground.createElevationSampler() methods. The elevation sampler created from the Ground will sample data from the first elevation layer that has data available. To control the layer used for elevation sampling and the sampling resolution, use ElevationLayer.createElevationSampler().

map.ground.load()
.then(function() {
// create an elevation sampler from a given extent
return view.map.ground.createElevationSampler(extent);
})
.then(function(elevationSampler) {
// use the elevation sampler to get z-values for a point, multipoint or polyline geometry
let zEnrichedGeometry = elevationSampler.queryElevation(geometry);
});

An instance of this class is also available in GroundView.elevationSampler. This can be used when the elevation values need to reflect the elevation currently displayed in the view.

let elevationSampler = view.groundView.elevationSampler;
// listen for elevation changes in the view
elevationSampler.on('changed', function() {
// enrich geometry with z-values from the elevation displayed in the view
let zEnrichedGeometry = elevationSampler.queryElevation(point);
});
See also

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

demResolution

readonly Property
Type
ElevationSamplerDemResolutionRange

The minimum and maximum resolution of the data in the sampler.

extent

readonly Property
Type
Extent | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.9

The extent within which the sampler can be queried.

noDataValue

readonly Property
Type
number | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.9

The value that is used to represent areas where there is no data available.

spatialReference

readonly Property
Type
SpatialReference
Since
ArcGIS Maps SDK for JavaScript 4.24

The spatial reference of the sampler.

Methods

MethodSignatureClass
elevationAt(x: number, y: number): number
emit
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
hasEventListener
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
queryElevation(geometry: Point): Point | null | undefined
queryElevation(geometry: Multipoint): Multipoint | null | undefined
queryElevation(geometry: Polyline): Polyline | null | undefined
queryElevation(geometry: Point | Polyline | Multipoint): Point | Polyline | Multipoint | null | undefined

elevationAt

Method
Signature
elevationAt (x: number, y: number): number
Since
ArcGIS Maps SDK for JavaScript 4.24

Get elevation for a coordinate specified in the spatial reference of the sampler. This is typically faster than queryElevation() when getting elevation for many coordinates that are guaranteed to be in the spatial reference of the sampler. If the coordinate is outside of the elevation sampler extent, then the samplers noDataValue will be returned.

Parameters
ParameterTypeDescriptionRequired
x

The x coordinate.

y

The y coordinate.

Returns
number

the elevation at the provided location. If no data could be sampled at the location, then the samplers noDataValue will be returned.

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters
ParameterTypeDescriptionRequired
type
Type

An event or an array of events to listen for.

listener
EventedCallback<this["@eventTypes"][Type]>

The function to call when the event fires.

Returns
ResourceHandle

Returns an event handler with a remove() method that should be called to stop listening for the event(s).

PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
Example
view.on("click", function(event){
// event is the event handle returned after the event fires.
console.log(event.mapPoint);
});

queryElevation

Method
Signature
queryElevation (geometry: Point): Point | null | undefined
Parameters
ParameterTypeDescriptionRequired
geometry
Returns
Point | null | undefined

queryElevation

Method
Signature
queryElevation (geometry: Multipoint): Multipoint | null | undefined
Parameters
ParameterTypeDescriptionRequired
geometry
Returns
Multipoint | null | undefined

queryElevation

Method
Signature
queryElevation (geometry: Polyline): Polyline | null | undefined
Parameters
ParameterTypeDescriptionRequired
geometry
Returns
Polyline | null | undefined

queryElevation

Method
Signature
queryElevation (geometry: Point | Polyline | Multipoint): Point | Polyline | Multipoint | null | undefined

Query elevation for a Point, Polyline or Multipoint geometry. A query will return a new geometry for which the z-values for each coordinate in the geometry are obtained from the elevation sampler. If the geometry used for the query is outside of the elevation sampler extent, then the returned geometry has the samplers noDataValue as z-values.

Parameters
ParameterTypeDescriptionRequired
geometry

The geometry to use for sampling elevation data.

Returns
Point | Polyline | Multipoint | null | undefined

The sampled geometry.

Events

changed

Event

Fires when the data in the sampler has changed. This event is only relevant for dynamic elevation samplers such as the elevation sampler on the GroundView.

bubbles composed cancelable
Example
view.groundView.elevationSampler.on("changed", function(evt) {
console.log("elevation has changed");
});

Type definitions

ElevationSamplerDemResolutionRange

Type definition

min

Property
Type
number

The minimum resolution.

max

Property
Type
number

The maximum resolution.