UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 5.46 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../Viewpoint.js";import i from"../../core/CollectionFlattener.js";import{destroyMaybe as s}from"../../core/maybe.js";import{whenOnce as r,watch as a,syncAndInitial as o}from"../../core/reactiveUtils.js";import{property as n,subclass as l}from"../../core/accessorSupport/decorators.js";import{initialize as p}from"../../core/workers/workers.js";import{isLoadedOrLoadFor as h}from"../../geometry/projectionUtils.js";import d from"../../layers/support/TileInfo.js";import g from"../View.js";import{Viewport2DBaseMixin as m}from"../Viewport2DBaseMixin.js";import c from"../2d/AnimationManager.js";import{GoToManager as u}from"../2d/GoToManager.js";import{layerView2DImporter as w}from"../2d/layerViewModuleImportUtils.js";import y from"../2d/tiling/TileInfoView.js";import"../2d/tiling/TileKey.js";import"../2d/tiling/TileQueue.js";import"../2d/tiling/TileStrategy.js";import{extentToScale as f}from"../2d/viewpointUtils.js";import V from"../2d/layers/features/support/TileStore.js";import{hitTest as v}from"../2d/support/hitTestUtils.js";import{Timeline as M}from"../2d/support/Timeline.js";let T,j,_,S;async function b(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s}]=await Promise.all([import("../2d/webglDeps.js"),import("../2d/mapViewDeps.js")]);T=e,j=t,_=i,S=s}let D=class extends(m(g)){constructor(e){super(e),this.stage=null,this.rootLayerViews=new i({getCollections:()=>[this.layerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.graphicsView=null,this.timeline=new M,this.goToManager=new u({view:this}),this.labelManager=null,this.map=null,this.surface=null,this.padding={top:0,right:0,bottom:0,left:0},p()}initialize(){this.addResolvingPromise(r(()=>this.ready))}destroy(){this.layerViewManager.clear(),this._set("preconditionsReady",!1),this.frameTask=s(this.frameTask),this.goToManager.destroy(),this.rootLayerViews.destroy()}get graphicsTileStore(){return new V(this.featuresTilingScheme)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=e.targetGeometry,i=this.spatialReference;return h(t.spatialReference,i)}async hitTest(e,t){return v(this,e,t)}goTo(e,t){return this.goToManager.goTo(e,t)}toMap(e){return this.stateManager.toMap(e)}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}loadAsyncDependencies(){return b()}hasLayerViewModule(e){return w.hasLayerViewModule(e)}importLayerView(e){return w.importLayerView(e)}_getDefaultViewpoint(){const{constraints:e,initialExtent:i,map:s,padding:r,size:a}=this;if(!e)return null;const o=s&&"initialViewProperties"in s?s.initialViewProperties:void 0,n=this.stateManager.getUserStartupOptions(this.size),l=o?.viewpoint,p=l?.targetGeometry?.extent??i,h=p?.center,d=l?.rotation??0,g=l?.scale||p&&f(p,[a[0]-r.left-r.right,a[1]-r.top-r.bottom]),m=n.center??h,c=n.rotation??d,u=n.scale??g;return m&&u?new t({targetGeometry:m,scale:u,rotation:c}):null}_updateStageChildren(){this.stage.removeAllChildren(),this.rootLayerViews.forEach(e=>{this.stage.addChild(e.container)});const e=this.graphicsView;this.stage.addChild(e.container)}_startup(){this.timeline.begin("VideoOperationalDataView Startup");const e=this._getDefaultViewpoint();this.stateManager.startup(e,this.size,this.spatialReference,this.defaultsFromMap.extent?.center),this.graphics.owner=this;const t=new _({view:this});this._set("labelManager",t);const i=new c({view:this});this._set("animationManager",i);const s=new S({view:this,animationManager:i});this._set("mapViewNavigation",s);const r=new y(d.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",r);const n=new T({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new j(r)});this._set("graphicsView",n),this.addHandles([this.rootLayerViews.on("change",()=>this._updateStageChildren()),this.stage.on("webgl-error",e=>this.fatalError=e.error),a(()=>this.stationary,e=>this.stage.stationary=e,o),a(()=>this.state.id,()=>this.stage.state=this.state,o)],"video-graphics-view"),this._updateStageChildren(),this.timeline.end("VideoOperationalDataView Startup"),this.frameTask.start(),this.stage.viewIsReady=!0,this._set("ready",!0)}_teardown(){this.removeHandles("video-graphics-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animation=null,this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.stage.destroy(),this.stage=null;const e=this.graphicsView;this._set("graphicsView",null),e.destroy(),this._set("featuresTilingScheme",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask.stop(),this.stationaryManager.clear(),this._set("ready",!1),this.stateManager.teardown()}};e([n()],D.prototype,"stage",void 0),e([n({readOnly:!0})],D.prototype,"featuresTilingScheme",void 0),e([n({readOnly:!0})],D.prototype,"graphicsTileStore",null),e([n()],D.prototype,"graphicsView",void 0),e([n({type:M,readOnly:!0})],D.prototype,"timeline",void 0),e([n()],D.prototype,"goToManager",void 0),e([n()],D.prototype,"labelManager",void 0),e([n()],D.prototype,"map",void 0),e([n({readOnly:!0})],D.prototype,"typeSpecificPreconditionsReady",null),e([n({readOnly:!0})],D.prototype,"surface",void 0),D=e([l("esri.views.video.VideoOperationalDataView")],D);const C=D;export{C as default};