import Accessor from "@arcgis/core/core/Accessor.js";
Subclasses
Graphic, Basemap, Camera, CameraLayout, Ground, Map, PopupTemplate, Viewpoint, Analysis, DimensionSimpleStyle, LengthDimension, LineOfSightAnalysisObserver, LineOfSightAnalysisTarget, SlicePlane, Viewshed, ElevationProfileDisplayUnits, ElevationProfileLine, ElevationProfileLineChartOptions, ElevationProfileLineViewOptions, ElevationProfileViewOptions, DiscreteOptions, MinDurationOptions, TotalDurationOptions, VolumeMeasurementCutFillOptions, VolumeMeasurementDisplayUnits, VolumeMeasurementInputUnits, AnalysisOriginWebScene, Collection, SharedTemplateMetadata, FocusArea, FocusAreaOutline, FocusAreas, ExpressionInfo, FormTemplate, Element, Input, Geometry, HeightModelInfo, SpatialReference, GeographicTransformation, GeographicTransformationStep, MeshComponent, MeshGeoreferencedVertexSpace, MeshLocalVertexSpace, MeshMaterial, MeshTexture, MeshTextureTransform, MeshTransform, MeshVertexAttributes, NavigationConstraint, Credential, OAuthInfo, ServerInfo, Layer, BuildingSublayer, ElevationSourceDefinitions, PointCloudFilter, AggregateField, BuildingFieldStatistics, BuildingFilter, BuildingFilterBlock, BuildingFilterMode, BuildingSummaryStatistics, CodedValue, Domain, ControlPoint, ControlPointsGeoreference, CornersGeoreference, FieldFormat, DimensionalDefinition, DisplayFilter, DisplayFilterInfo, EditFieldsInfo, EditingCapabilities, ElevationSampler, ExpressionInfo, ExtentAndRotationGeoreference, FacilityLayerInfo, FeatureEffect, FeatureFilter, FeatureReductionBinning, FeatureReductionCluster, FeatureReductionSelection, FeatureTemplate, FeatureType, Field, FieldConfiguration, GeometryFieldsInfo, MediaElementBase, KMLMapImage, KMLSublayer, LOD, LabelClass, LabelExpressionInfo, LayerFloorInfo, LevelLayerInfo, LocalMediaElementSource, MapImage, MosaicRule, MultidimensionalSubset, OrderByInfo, ParquetGeometryEncodingLocation, ParquetGeometryEncodingWkb, PixelBlock, PlaybackInfo, PublishingInfo, PurgeOptions, RasterBandInfo, RasterFunction, RasterInfo, RasterSensorInfo, Relationship, RouteStopSymbols, RouteSymbols, SceneFilter, SceneModification, SiteLayerInfo, StreamConnection, Sublayer, Subtype, SubtypeSublayer, TelemetryData, TelemetryDisplay, TileInfo, TileMatrixSet, TimeInfo, TrackInfo, TrackPartInfo, VideoTimeExtent, WMSSublayer, WMTSStyle, WMTSSublayer, VoxelColorStop, VoxelDynamicSection, VoxelFormat, VoxelIsosurface, VoxelOpacityStop, VoxelRangeFilter, VoxelSlice, VoxelTransferFunctionStyle, VoxelUniqueValue, VoxelVariable, VoxelVariableStyle, VoxelVolume, VoxelVolumeStyle, ChronologicalLayoutSettings, LayoutSettings, LinkChartProperties, NonspatialDataDisplay, OrganicLayoutSettings, CircuitManager, Network, UnitIdentifierManager, UtilityNetworkTraceAnalysis, Circuit, CircuitLocation, CircuitPath, CircuitPathConnectivityElement, CircuitSection, NamedTraceConfiguration, NetworkSystemLayers, Subcircuit, Terminal, TerminalConfiguration, ValidateNetworkTopologyResult, TraceConfiguration, TraceResult, ElementExpressionInfo, ExpressionInfo, FieldInfo, LayerOptions, RelatedRecordsInfo, Content, MediaInfo, ChartMediaInfoValue, ChartMediaInfoValueSeries, ImageMediaInfoValue, AttachmentsOrderByInfo, FieldInfoFormat, RelatedRecordsInfoFieldOrder, UtilityNetworkAssociationType, Portal, PortalFolder, PortalGroup, PortalItem, PortalItemResource, PortalQueryParams, PortalQueryResult, PortalRating, PortalUser, Renderer, FlowRenderer, PointCloudRenderer, RasterColormapRenderer, RasterShadedReliefRenderer, RasterStretchRenderer, VectorFieldRenderer, AttributeColorInfo, AuthoringInfo, AuthoringInfoClassBreakInfo, AuthoringInfoFieldInfo, AuthoringInfoVisualVariable, ClassBreakInfo, ColormapInfo, DotDensityLegendOptions, HeatmapColorStop, HeatmapLegendOptions, OthersCategory, RasterPresetRenderer, RendererLegendOptions, UniqueValue, UniqueValueClass, UniqueValueGroup, UniqueValueInfo, ColorClassBreakInfo, ColorModulation, ColorUniqueValueInfo, PointSizeAlgorithm, VisualVariable, ColorSizeStop, ColorStop, OpacityStop, SizeStop, VisualVariableLegendOptions, FeatureService, GPOptions, DataModel, GraphObject, GraphObjectType, FieldIndex, GraphDataModelOperationResult, GraphApplyEdits, GraphApplyEditsResult, GraphDataModelSingletonOperationResult, GraphProperty, GraphQuery, GraphQueryResult, GraphQueryResultHeader, GraphQueryStreamingResult, GraphSearch, InputQuantizationParameters, KnowledgeGraph, OutputQuantizationParameters, Path, SearchIndex, ServiceDefinition, SourceTypeValueBehavior, CIMFilteredFindPathsConfiguration, CIMFilteredFindPathsEntity, CIMFilteredFindPathsPathFilter, CIMKGTraversalDirection, FindPathsToolSettings, DynamicDataLayer, DynamicMapLayer, JoinTableDataSource, QueryTableDataSource, RasterDataSource, TableDataSource, CircuitTraceResult, CircuitVerifyResult, ExportCircuitsParameters, QueryCircuitsParameters, VerifyCircuitsParameters, AggregatedGeometry, Association, AssociationGeometriesResult, FunctionResult, NetworkElement, QueryAssociationsParameters, QueryAssociationsResult, QueryNamedTraceConfigurationsParameters, SynthesizeAssociationGeometriesParameters, TraceLocation, TraceParameters, ValidateNetworkTopologyParameters, UnitQueryResult, AttachmentInfo, AddressCandidate, AddressToLocationsParameters, AddressesToLocationsParameters, ColorRamp, ArealUnit, AreasAndLengthsParameters, AttachmentQuery, FeatureSet, AttributeBinsGrouping, AttributeBinsQuery, BinParametersBase, BaseImageMeasureParameters, BaseImageMeasureResult, BaseImageMeasureResultValue, BufferParameters, CameraInfo, ClosestFacilityParameters, ClosestFacilitySolveResult, DataFile, DataLayer, DateBinTimeInterval, DensifyParameters, DirectionLine, DirectionPoint, DirectionsEvent, DirectionsString, DistanceParameters, PlacesParameters, FindImagesParameters, FindImagesResult, FindParameters, FindResult, GPMessage, GeneralizeParameters, IdentifyParameters, IdentifyResult, ImageAngleParameters, ImageAngleResult, ImageBoundaryParameters, ImageBoundaryResult, ImageGPSInfo, ImageGPSInfoParameters, ImageGPSInfoResult, ImageHistogramParameters, ImageIdentifyParameters, ImageIdentifyResult, ImageInspectionInfo, ImageParameters, ImagePixelLocationParameters, ImagePixelLocationResult, ImageSample, ImageSampleParameters, ImageSampleResult, ImageToMapMultirayParameters, ImageToMapParameters, ImageUrlParameters, ImageUrlResult, ImageVolume, ImageVolumeParameters, ImageVolumeResult, JobInfo, LastMileDeliveryParameters, LegendLayer, LengthsParameters, LinearUnit, LocateSettingBase, LocateSettingSource, LocateSettings, LocateSettingsOverrides, LocationToAddressParameters, MapToImageParameters, MeasureAreaFromImageResult, MeasureFromImageParameters, MeasureLengthFromImageResult, NetworkAttribute, NetworkServiceDescription, NetworkUrl, OffsetParameters, ParameterValue, PlaceResult, PlacesQueryResult, PointBarrier, PolygonBarrier, PolylineBarrier, PrintParameters, PrintTemplate, ProjectParameters, QuantizationParameters, Query, RasterData, RelationParameters, RelationshipQuery, RouteInfo, RouteParameters, RouteResult, RouteSolveResult, ServiceAreaParameters, ServiceAreaSolveResult, StatisticDefinition, Stop, SuggestLocationsParameters, SuggestionCandidate, TimeUnit, TopFeaturesQuery, TopFilter, TravelMode, TrimExtendParameters, AlterVersionParameters, PostResult, ReconcileParameters, ReconcileResult, CreateVersionParameters, GetVersionInfosParameters, BasemapStyle, MapFloorInfo, ActionBase, Symbol, Symbol3DLayer, Font, LineStyleMarker3D, LineSymbolMarker, Callout3D, LineCallout3DBorder, Edges3D, LinePattern3D, Pattern3D, ElevationInfo, FeatureExpressionInfo, IconSymbol3DLayerResource, ObjectSymbol3DLayerResource, OccludedVisibility, StyleOrigin, Symbol3DAnchorPosition2D, Symbol3DAnchorPosition3D, Symbol3DEmissive, Symbol3DMaterial, Symbol3DHalo, Symbol3DIconOutline, Symbol3DOutline, Symbol3DTextBackground, Symbol3DVerticalOffset, AttributeTableTemplate, AttributeTableElement, FieldOrder, TimeExtent, TimeInterval, VersionManagementService, VersionManager, VersioningState, BasemapView, GroundView, View, Magnifier, SelectionManager, Theme, VideoView, ViewAnimation, MapViewConstraints, ViewState, AnalysisView, LayerView, LineOfSightAnalysisResult, VolumeMeasurementResult, AltitudeConstraint, ClipDistanceConstraint, Constraints, TiltConstraint, CloudyWeather, Environment, FoggyWeather, RainyWeather, SnowyWeather, SunLighting, SunnyWeather, VirtualLighting, MediaLayerInteractionOptions, MediaLayerInteractionReshapeOptions, RenderCamera, RenderNode, LengthDimensionResult, ElevationProfileResult, Draw, DrawAction, Input, GamepadInputDevice, GamepadSettings, Tooltip, SketchLabelOptions, SketchTooltipOptions, SketchTooltipVisibleElements, SketchValueOptions, Units, FeatureSnappingLayerSource, SnappingOptions, BuildingComponentSublayerView, Navigation, NavigationActionMap, GamepadSettings, HighlightOptions, UI, GeotriggersInfo, IPSInfo, Widgets, Search, SearchLayer, SearchLayerField, SearchTable, SearchTableField, Viewing, DeviceLocationFeed, ExpressionInfo, FeatureFenceParameters, FeatureFilter, FeatureLayerSource, Geotrigger, GeotriggerNotificationOptions, AppleIPSProperties, Configuration, GNSSProperties, PathSnappingProperties, PositioningService, SmoothingProperties, SlideThumbnail, FloorFilter, TimeSlider, ApplicationProperties, Bookmark, InitialViewProperties, ColorBackground, ApplicationProperties, Glow, InitialViewProperties, Presentation, Slide, SlideLegendInfo, Background, Description, FeatureReference, FeatureReferenceId, LayerReference, SlideElements, SlideEnvironment, SlideGround, SlidePopupInfo, SlideVisibleLayer, Title, Widget, AreaMeasurement2DViewModel, AreaMeasurement3DViewModel, AttachmentsViewModel, AttributionViewModel, BasemapGalleryViewModel, BasemapGalleryItem, LocalBasemapsSource, BasemapLayerListViewModel, BasemapLayerListVisibleElements, BasemapToggleViewModel, BatchAttributeFormViewModel, VisibleElements, BatchFormInputs, InputBase, BookmarksViewModel, BookmarksVisibleElements, BuildingExplorerViewModel, BuildingNumericFilterViewModel, CatalogLayerListViewModel, CatalogLayerListVisibleElements, CompassViewModel, CoordinateConversionViewModel, Conversion, Format, DaylightViewModel, VisibleElements, DirectLineMeasurement3DViewModel, DirectionalPadViewModel, VisibleElements, DirectionsViewModel, DirectionsVisibleElements, DistanceMeasurement2DViewModel, Workflow, CreateFeaturesWorkflowData, EditorViewModel, Edits, MergeFeaturesWorkflowData, SplitFeatureWorkflowData, UpdateFeaturesWorkflowData, UpdateWorkflowData, VisibleElements, EditorItem, ElevationProfileLine, ElevationProfileViewModel, ElevationProfileVisibleElements, ExpandViewModel, FeatureViewModel, InputBase, FeatureFormViewModel, VisibleElements, Column, ColumnMenuVisibleElements, TableMenuVisibleElements, VisibleElements, ColumnTemplateBase, AttachmentsViewOptions, TableTemplate, FeatureTemplatesViewModel, TemplateItem, TemplateItemGroup, VisibleElements, FeaturesViewModel, FeaturesVisibleElements, FloorFilterViewModel, FullscreenViewModel, HistogramViewModel, SliderViewModel, HomeViewModel, LayerListViewModel, LayerListVisibleElements, ListItem, LegendViewModel, ActiveLayerInfo, LineOfSightTarget, LineOfSightViewModel, LinkChartLayoutSwitcherViewModel, GeolocationPositioning, MeasurementViewModel, NavigationToggleViewModel, OrientedImageryViewerViewModel, PopupVisibleElements, CustomTemplate, FileLink, LayoutOptions, LayoutTemplateInfo, MapSurroundInfoBase, PrintViewModel, TemplateOptions, ScaleBarViewModel, ScaleRangeSliderViewModel, ScaleRanges, SearchSource, SearchViewModel, DiscreteOptions, DurationOptions, ShadowCastViewModel, ShadowCastVisibleElements, ThresholdOptions, CreateToolVisibilityMap, SelectionToolVisibilityMap, SketchViewModel, VisibleElements, SliceViewModel, SwipeViewModel, ListItem, TableListViewModel, TableListVisibleElements, TimeSliderViewModel, UtilityNetworkAssociationsViewModel, VisibleElements, VisibleElementsSettingsPane, UtilityNetworkTraceViewModel, UtilityNetworkTraceAnalysisViewModel, UtilityNetworkValidateTopologyViewModel, ValuePickerSliderVisibleElements, ValuePickerVisibleElements, VersionManagementViewModel, VideoPlayerViewModel, VisibleElements, WeatherViewModel, ZoomViewModel, GridControlsViewModel, VisibleElements, SnappingControlsViewModel, VisibleElements
Since
ArcGIS Maps SDK for JavaScript 4.0

Accessor is an abstract class that facilitates the access to instance properties as well as a mechanism to watch for property changes. It is possible to watch for a property changes by using the watch() method.

See also

Constructors

Constructor

Constructor

Parameters

ParameterTypeDescriptionRequired
args
any[]

Properties

PropertyTypeClass
readonly
readonly
readonly

declaredClass

readonly Property
Type
string
Since
ArcGIS Maps SDK for JavaScript 4.7

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

destroyed

readonly Property
Type
boolean

initialized

readonly Property
Type
boolean

Set to true once the initialize function has executed.

Methods

MethodSignatureClass
createSubclass(classDefinition?: any): typeof Accessor
protected
_get<T>(propertyName: string): T
protected
_set(propertyName: any, value: any): this
addHandles<T>(handleOrHandles: ResourceHandle | ResourceHandle[], groupKey?: GroupKey<T>): void
destroy(): void
hasHandles<T>(groupKey?: GroupKey<T>): boolean
protected
notifyChange(propertyName: string): void
removeHandles<T>(groupKey?: GroupKey<T>): void
set
set<T>(path: string, value: T): this
set
set(props: Record<string, any>): this
deprecated
watch(path: any, callback: WatchCallback): ResourceHandle

createSubclass

static Method
Signature
createSubclass (classDefinition?: any): typeof Accessor
Since
ArcGIS Maps SDK for JavaScript 4.21

Creates a subclass of the class calling this method.

See also

Parameters

ParameterTypeDescriptionRequired
classDefinition
any

An object with properties and methods to mix in to the newly created class.

Returns
typeof Accessor

Returns a constructor of the newly created class.

_get

protected Method
Signature
_get <T>(propertyName: string): T
Type parameters
<T>

Gets the value stored for a property. It can be used when creating a class extending Accessor to get the value stored internally without calling the property getter. For example, this may be used to return a default value for a property when the property is accessed before a value is set on it.

Parameters

ParameterTypeDescriptionRequired
propertyName

The name of the property to get.

Returns
T

The property's value.

Example
get propertyWithDefault() {
return this._get("propertyWithDefault") ?? defaultValue;
}

_set

protected Method
Signature
_set (propertyName: any, value: any): this

Sets the stored value of a property. Calling _set directly updates the stored value and skip checks like defined in the @property() decoration like readOnly or type. This is typically used to update the stored value in a property setter, or to update a read only property.

Parameters

ParameterTypeDescriptionRequired
propertyName
any

The name of the property to set.

value
any

The new value to set on the property.

Returns
this
Example
@subclass("Counter")
class Counter {
@property({ readOnly: true })
value = 0;
increment() {
this._set("value", this.value + 1);
}
}

addHandles

Method
Signature
addHandles <T>(handleOrHandles: ResourceHandle | ResourceHandle[], groupKey?: GroupKey<T>): void
Type parameters
<T>
Since
ArcGIS Maps SDK for JavaScript 4.25

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
() => !view.updating,
() => {
wkidSelect.disabled = false;
},
{ once: true }
);
this.addHandles(handle);
// Destroy the object
this.destroy();

Parameters

ParameterTypeDescriptionRequired
handleOrHandles

Handles marked for removal once the object is destroyed.

groupKey

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with removeHandles(). If no key is provided the handles are added to a default group.

Returns
void

destroy

Method
Signature
destroy (): void
Returns
void

hasHandles

Method
Signature
hasHandles <T>(groupKey?: GroupKey<T>): boolean
Type parameters
<T>
Since
ArcGIS Maps SDK for JavaScript 4.25

Returns true if a named group of handles exist.

Parameters

ParameterTypeDescriptionRequired
groupKey

A group key.

Returns
boolean

Returns true if a named group of handles exist.

Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
obj.removeHandles("watch-view-updates");
}

notifyChange

protected Method
Signature
notifyChange (propertyName: string): void

Marks a property has changed. The next time the property is accessed, the getter for that property will be invoked. If the property is watched, the watcher callbacks will be called if the new value of the property has effectively changed.

Parameters

ParameterTypeDescriptionRequired
propertyName

The name of the property that may have changed.

Returns
void

removeHandles

Method
Signature
removeHandles <T>(groupKey?: GroupKey<T>): void
Type parameters
<T>
Since
ArcGIS Maps SDK for JavaScript 4.25

Removes a group of handles owned by the object.

Parameters

ParameterTypeDescriptionRequired
groupKey

A group key or an array or collection of group keys to remove.

Returns
void
Example
obj.removeHandles(); // removes handles from default group
obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

set

Method
Signature
set <T>(path: string, value: T): this
Type parameters
<T>

Sets the value of a property.

Call set() with a property name and a value to change the value of the property.

// setting the basemap of the map
map.set("basemap", "topo-vector");
// is equivalent to
map.basemap = "topo-vector";
// currying set
let updateViewScale = view.set.bind(view, "scale");
updateViewScale(5000);

set() can be called with the path to a property and a value. The property is not set if a property in the path doesn't exist.

// updating the title of the basemap
map.set("basemap.title", "World Topographic Map");
// is equivalent to
if (map.basemap != null) {
map.basemap.title = "World Topographic Map";
}

Parameters

ParameterTypeDescriptionRequired
path

The path to the property to set

value
T

The new value to set on the property.

Returns
this

The instance.

set

Method
Signature
set (props: Record<string, any>): this

An object with key-value pairs may be passed into set() to update multiple properties at once.

// setting a viewpoint on the view
view.set({
center: [-4.4861, 48.3904],
scale: 5000
});
// currying set
let updateView = view.set.bind(view);
updateView({
center: [-4.4861, 48.3904],
scale: 5000
});

Parameters

ParameterTypeDescriptionRequired
props

an object of key-value pairs

Returns
this

The instance.

watch

deprecated Method
Signature
watch (path: any, callback: WatchCallback): ResourceHandle

Watches for property changes on the instance. For additional capabilities when observing changes on properties, see reactiveUtils.

Watching for property changes is essential for tracking changes on objects. To start watching for changes on a property, call watch() with the property name and a callback function that will execute each time the property changes.

let handle = mapview.watch("scale", function(newValue, oldValue, propertyName, target) {
console.log(propertyName + " changed from " + oldValue + " to " + newValue);
});

To stop watching for changes, call the remove() method on the object that watch() returns.

handle.remove();

It is important to store the resulting objects from watch() to properly clean up the references.

let viewHandles = [];
function setView(view) {
// remove the handles for the current view.
viewHandles.forEach(function(handle) {
handle.remove();
});
viewHandles.length = 0;
this.view = view;
// watch for properties on the newly set view.
if (view) {
viewHandles.push(
view.watch("scale", scaleWatcher);
);
}
}
setView(mapView);
setView(null);

Like get() and set(), it is possible to watch for a property deep in the object hierarchy by passing a path. If a property in the path doesn't exist the watch callback is called with undefined.

let view = new SceneView({
map: new Map({
basemap: "streets-vector"
})
});
view.watch("map.basemap.title", (newValue, oldValue) => {
console.log("basemap's title changed from " + oldValue + " to " + newValue);
});
view.map.basemap = "topo-vector";
// output: "basemap's title changed from Streets to Topographic"
view.map = null;
// output: "basemap's title changed from Topographic to undefined"

Pass a comma delimited list of property paths, or an array of property paths, to watch multiple properties with the same callback. Use the third parameter of the callback call to determine what property changed.

view.watch("center, scale, rotation", (newValue, oldValue, propertyName) => {
console.log(propertyName + " changed");
});
// equivalent of
view.watch(["center", "scale", "rotation"], (newValue, oldValue, propertyName) => {
console.log(propertyName + " changed");
});
// equivalent of
let callback = (newValue, oldValue, propertyName) => {
console.log(propertyName + " changed");
}
view.watch("center", callback);
view.watch("scale", callback);
view.watch("rotation", callback);

Accessor doesn't call the watch callbacks for a property immediately after its value changes. Instead, when a property's value changes and if that property is watched, Accessor schedules a notification which is then processed at a later time. Properties that change frequently like view.scale can be watched without having to throttle the callback.

// Divides the view.scale three times
view.watch("scale", (newValue, oldValue) => {
console.log("view's scale changed from " + oldValue + " to " + newValue);
});
console.log("current view scale: " + view.scale);
view.scale = view.scale / 2;
view.scale = view.scale / 2;
view.scale = view.scale / 2;
console.log("current view scale: " + view.scale);
// output the following:
// current view scale: 36978595.474472
// current view scale: 4622324.434309
// view's scale changed from 36978595.474472 to 4622324.434309

Parameters

ParameterTypeDescriptionRequired
path
any

The property or properties to watch. Multiple properties can be specified as a comma-separated list.

callback

The callback to execute when the property value has changed.

Returns
ResourceHandle

A watch handle

Type definitions

GroupKey

Type definition
Type parameters
<T>
Supertypes
Exclude<T‚ ResourceHandle>

WatchCallback

deprecated Type definition

Callback to be called when a watched property changes.

Parameters

ParameterTypeDescriptionRequired
newValue
any

The new value of the watched property.

oldValue
any

The old value of the watched property.

propertyName

The property name.

target

The object containing the property being watched.

Returns
void