import ElevationSampler from "@arcgis/core/layers/support/ElevationSampler.js";
            const ElevationSampler = await $arcgis.import("@arcgis/core/layers/support/ElevationSampler.js");
            @arcgis/core/layers/support/ElevationSampler
        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);
});
Property Overview
| Name | Type | Summary | Class | 
|---|---|---|---|
| The minimum and maximum resolution of the data in the sampler. | ElevationSampler | ||
| The extent within which the sampler can be queried. | ElevationSampler | ||
| The value that is used to represent areas where there is no data available. | ElevationSampler | ||
| The spatial reference of the sampler. | ElevationSampler | 
Property Details
- 
  
  demResolutionPropertydemResolution Objectreadonly
- 
  
    The minimum and maximum resolution of the data in the sampler. 
- 
  
  
  
  
  
  
  
    Since: ArcGIS Maps SDK for JavaScript 4.9ElevationSampler since 4.7, extent added at 4.9. 
- 
  
    The extent within which the sampler can be queried. 
- 
  
  
  
  
  
  
  
    Since: ArcGIS Maps SDK for JavaScript 4.9ElevationSampler since 4.7, noDataValue added at 4.9. 
- 
  
    The value that is used to represent areas where there is no data available. 
- 
  
  spatialReferencePropertyspatialReference SpatialReferencereadonlySince: ArcGIS Maps SDK for JavaScript 4.24ElevationSampler since 4.7, spatialReference added at 4.24. 
- 
  
    The spatial reference of the sampler. 
Method Overview
| Name | Return Type | Summary | Class | 
|---|---|---|---|
| Get elevation for a coordinate specified in the spatial reference of the sampler. | ElevationSampler | ||
| Emits an event on the instance. | ElevationSampler | ||
| Indicates whether there is an event listener on the instance that matches the provided event name. | ElevationSampler | ||
| Registers an event handler on the instance. | ElevationSampler | ||
| Query elevation for a Point, Polyline or Multipoint geometry. | ElevationSampler | 
Method Details
- 
  
  elevationAtMethodelevationAt(x, y){Number}Since: ArcGIS Maps SDK for JavaScript 4.24ElevationSampler since 4.7, elevationAt added at 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. ReturnsType Description Number The sampled elevation. 
- 
  
  onMethodon(type, listener){Object}
- 
  
  
    Registers an event handler on the instance. Call this method to hook an event with a listener. ParametersReturnsType Description Object Returns an event handler with a remove()method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
- 
  
  queryElevationMethodqueryElevation(geometry){Point |Multipoint |Polyline |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. Parametergeometry Point|Multipoint|PolylineThe geometry to use for sampling elevation data. ReturnsType Description Point | Multipoint | Polyline | null | undefined The sampled geometry. 
Event Overview
| Name | Type | Summary | Class | 
|---|---|---|---|
|  | Fires when the data in the sampler has changed. | ElevationSampler | 
Event Details
- 
  
  
    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. Exampleview.groundView.elevationSampler.on("changed", function(evt) { console.log("elevation has changed"); });