UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.41 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import"../../../../core/Error.js";import"../../../../core/Logger.js";import{watch as r,on as o}from"../../../../core/reactiveUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Point.js";import{center as l}from"../../../../geometry/support/aaBoundingRect.js";let c=class extends t{get surface(){return this.view.map?.ground}get surfaceView(){return this.view.basemapTerrain}get renderLocation(){if(!this.location)return null;const e=a();return this.view.renderCoordsHelper.toRenderCoords(this.location,e),e}constructor(e){super(e),this.location=null,this._updateController=null}initialize(){this.view.state.isLocal&&(this.addHandles([r((()=>[this.surfaceView?.spatialReference,this.surfaceView?.extent]),(()=>this._update())),o((()=>this.surface?.layers),"change",(()=>this._update()))]),this._update())}_update(){if(this._updateController&&(this._updateController.abort(),this._updateController=null),null==this.surfaceView?.extent||null==this.surfaceView.spatialReference)return void this._set("location",null);const e=l(this.surfaceView.extent),t=new n({x:e[0],y:e[1],z:0,spatialReference:this.surfaceView.spatialReference});this.surface&&this.surface.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this.surface.queryElevation(t,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then((e=>{this._updateController=null,this._set("location",e.geometry)})).catch((e=>{}))):this._set("location",t)}};e([s({constructOnly:!0})],c.prototype,"view",void 0),e([s({constructOnly:!0})],c.prototype,"cache",void 0),e([s()],c.prototype,"surface",null),e([s()],c.prototype,"surfaceView",null),e([s({readOnly:!0})],c.prototype,"location",void 0),e([s({readOnly:!0})],c.prototype,"renderLocation",null),c=e([i("esri.views.3d.support.pointsOfInterest.StableSurfaceCenter")],c);export{c as StableSurfaceCenter};