12345 |
- /*
- All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- See https://js.arcgis.com/4.25/esri/copyright.txt for details.
- */
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Map.js";import i from"../TimeExtent.js";import r from"../core/Accessor.js";import{createTask as a}from"../core/asyncUtils.js";import s from"../core/Collection.js";import o from"../core/CollectionFlattener.js";import n from"../core/Error.js";import l from"../core/Evented.js";import{HandleOwnerMixin as p}from"../core/HandleOwner.js";import{makeHandle as d}from"../core/handleUtils.js";import h from"../core/Loadable.js";import y from"../core/Logger.js";import{destroyMaybe as c,isSome as u,abortMaybe as m}from"../core/maybe.js";import{EsriPromiseMixin as f}from"../core/Promise.js";import{after as g}from"../core/promiseUtils.js";import{watch as w,whenOnce as v,when as M,sync as V}from"../core/reactiveUtils.js";import{property as R}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as _}from"../core/accessorSupport/decorators/subclass.js";import{owningCollectionProperty as S}from"../core/support/OwningCollection.js";import j from"../geometry/Extent.js";import F from"../geometry/HeightModelInfo.js";import L from"../geometry/SpatialReference.js";import{equals as C}from"../geometry/support/spatialReferenceUtils.js";import{AnalysesCollection as O}from"../support/AnalysesCollection.js";import{GraphicsCollection as E}from"../support/GraphicsCollection.js";import{BasemapView as b}from"./BasemapView.js";import x from"./LayerViewManager.js";import I from"./Magnifier.js";import T from"./ToolViewManager.js";import q from"./input/Input.js";import{ViewEvents as D}from"./input/ViewEvents.js";import U from"./navigation/Navigation.js";import{DefaultsFromMap as k}from"./support/DefaultsFromMap.js";var P;let W=P=class extends(p(l.EventedMixin(f(r)))){constructor(e){super(e),this._userSpatialReference=null,this._cursor=null,this.allLayerViews=new o({getCollections:()=>[this.basemapView?.baseLayerViews,this.groundView?.layerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:e=>e.layerViews}),this.groundView=null,this.basemapView=null,this.fatalError=null,this.graphics=new E,this.analyses=new O,this.typeSpecificPreconditionsReady=!0,this.layerViews=new s,this.magnifier=new I,this.padding={left:0,top:0,right:0,bottom:0},this.ready=!1,this.spatialReferenceWarningDelay=1e3,this.supportsGround=!0,this.timeExtent=null,this.type=null,this.scale=null,this.updating=!1,this.initialExtentRequired=!0,this.input=new q,this.navigation=new U,this.layerViewManager=null,this.analysisViewManager=null,this.isHeightModelInfoRequired=!1,this.width=null,this.height=null,this.resizing=!1,this.suspended=!1,this.viewEvents=new D(this),this.persistableViewModels=new s,this._isValid=!1,this._readyCycleForced=!1,this.handles.add(w((()=>this.preconditionsReady),(e=>{e?(this._currentSpatialReference=this.spatialReference,P.views.add(this)):(this._currentSpatialReference=null,P.views.remove(this)),this.notifyChange("spatialReference"),!e&&this.ready?(this.toolViewManager?.detach(),u(this.analysisViewManager)&&this.analysisViewManager.detach(),this.layerViewManager?.clear(),this._teardown()):e&&!this.ready&&(this._startup(),u(this.analysisViewManager)&&this.analysisViewManager.attach(),this.toolViewManager.attach())}),V))}initialize(){this.addResolvingPromise(this.validate().then((()=>(this._isValid=!0,v((()=>this.ready)))))),this.basemapView=new b({view:this}),this.layerViewManager=new x({view:this,layerViewImporter:{importLayerView:e=>this.importLayerView(e),hasLayerViewModule:e=>this.hasLayerViewModule(e)},supportsGround:this.supportsGround}),this.toolViewManager=new T({view:this}),this._setupSpatialReferenceLogger(),this.handles.add([w((()=>this.initialExtentRequired),(e=>this.defaultsFromMap.required={...this.defaultsFromMap.required,extent:e}),{sync:!0,initial:!0}),w((()=>this.ready),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.suspended=e,this.defaultsFromMap.userSpatialReference=e?this.spatialReference:this._userSpatialReference)}),{sync:!0}),w((()=>this._userSpatialReference),(e=>{this.defaultsFromMap&&(this.defaultsFromMap.userSpatialReference=e)}),{sync:!0,initial:!0})])}_setupSpatialReferenceLogger(){let e=null;this.handles.add([w((()=>this.defaultsFromMap?.ready),(t=>{const i=this.map?.allLayers.length>0;if(t&&!this.spatialReference&&i){if(u(e))return;const t=d((()=>e=m(e)));e=a((async t=>{try{await g(this.spatialReferenceWarningDelay,null,t)}catch{return}finally{e=null}y.getLogger(this.declaredClass).warn("#spatialReference","no spatial reference could be derived from the currently added map layers")})),this.handles.add(t,"spatial-reference-logger-task")}else this.handles.remove("spatial-reference-logger-task")}),{sync:!0})])}destroy(){if(this.destroyed)return;this.viewEvents.destroy(),this.allLayerViews.destroy(),this.navigation&&(this.navigation.destroy(),this._set("navigation",null)),this.graphics=c(this.graphics),this.analyses=c(this.analyses),this.handles.remove("defaultsFromMap"),this.defaultsFromMap.destroy(),this._set("defaultsFromMap",null),c(this.analysisViewManager),this.toolViewManager=c(this.toolViewManager),this.layerViewManager=c(this.layerViewManager),this.basemapView=c(this.basemapView),this.invalidate(),this._emitter.clear(),this.handles.removeAll();const e=this.map;this.map=null,e?.destroy()}_startup(){this._set("ready",!0)}_teardown(){this._set("ready",!1)}whenReady(){return Promise.resolve(this)}toMap(){return y.getLogger(this.declaredClass).error("#toMap()","Not implemented on this instance of View"),null}get activeTool(){return this.toolViewManager?.activeTool}set activeTool(e){this.toolViewManager&&(this.toolViewManager.activeTool=e)}get animation(){return this._get("animation")}set animation(e){this._set("animation",e)}get _defaultsFromMapSettings(){return{}}get defaultsFromMap(){return new k({required:{tileInfo:!1,heightModelInfo:!1,extent:!1},map:()=>this.map,getSpatialReferenceSupport:e=>this.getSpatialReferenceSupport(e),...this._defaultsFromMapSettings})}get extent(){return this._get("extent")}set extent(e){this._set("extent",e)}get heightModelInfo(){return this.getDefaultHeightModelInfo()}get interacting(){return this.navigating}get navigating(){return!1}get preconditionsReady(){return!(this.fatalError||!this._isValid||this._readyCycleForced||!this.map||h.isLoadable(this.map)&&!this.map.loaded||0===this.width||0===this.height||!this.spatialReference||!this._validateSpatialReference(this.spatialReference)||!this._currentSpatialReference&&!this.defaultsFromMap?.ready||!this.typeSpecificPreconditionsReady)}set map(e){e!==this._get("map")&&(e?.destroyed&&(y.getLogger(this.declaredClass).warn("#map","The provided map is already destroyed",{map:e}),e=null),h.isLoadable(e)&&e.load().catch((()=>{})),this.constructed&&(this.forceReadyCycle(),this._currentSpatialReference=null),this._set("map",e))}get spatialReference(){let e=this._userSpatialReference||this._currentSpatialReference||this.getDefaultSpatialReference()||null;return e&&this.defaultsFromMap?.required?.heightModelInfo&&(e=e.clone(),e.vcsWkid=this.defaultsFromMap.vcsWkid,e.latestVcsWkid=this.defaultsFromMap.latestVcsWkid),e}set spatialReference(e){const t=!C(e,this._get("spatialReference"));this._set("_userSpatialReference",e),t&&(this._set("spatialReference",e),this._spatialReferenceChanged(e))}_spatialReferenceChanged(e){}get stationary(){return!this.animation&&!this.navigating&&!this.resizing}get tools(){return this.toolViewManager?.tools}get initialExtent(){return this.defaultsFromMap?.extent}get cursor(){const e=this.toolViewManager?this.toolViewManager.cursor:null;return u(e)?e:this._cursor||"default"}set cursor(e){this._cursor=e,this.notifyChange("cursor")}get size(){return[this.width,this.height]}whenLayerView(e){return this.layerViewManager.whenLayerView(e)}getDefaultSpatialReference(){return this.defaultsFromMap?.spatialReference}getDefaultHeightModelInfo(){return(this.map&&"heightModelInfo"in this.map?this.map.heightModelInfo:void 0)??this.defaultsFromMap?.heightModelInfo??null}importLayerView(e){throw new n("importLayerView() not implemented")}hasLayerViewModule(e){return!1}async validate(){}invalidate(){this._isValid=!1}getSpatialReferenceSupport(){return{constraints:null}}_validateSpatialReference(e){return u(this.getSpatialReferenceSupport({spatialReference:e}))}when(e,t){return this.isResolved()&&!this.ready&&y.getLogger(this.declaredClass).warn("#when()","Calling view.when() while the view is no longer ready but was already resolved once will resolve immediately. Use reactiveUtils.whenOnce(() => view.ready).then(...) instead."),super.when(e,t)}forceReadyCycle(){this.ready&&(M((()=>!1===this.preconditionsReady),(()=>this._readyCycleForced=!1),{once:!0}),this._readyCycleForced=!0)}addAndActivateTool(e){this.toolViewManager.tools.add(e),this.activeTool=e}tryFatalErrorRecovery(){this.fatalError=null}};W.views=new s,e([R()],W.prototype,"_userSpatialReference",void 0),e([R()],W.prototype,"activeTool",null),e([R({readOnly:!0})],W.prototype,"allLayerViews",void 0),e([R()],W.prototype,"groundView",void 0),e([R()],W.prototype,"animation",null),e([R()],W.prototype,"basemapView",void 0),e([R({readOnly:!0})],W.prototype,"_defaultsFromMapSettings",null),e([R()],W.prototype,"defaultsFromMap",null),e([R()],W.prototype,"fatalError",void 0),e([R({type:j})],W.prototype,"extent",null),e([R(S(E,"graphics"))],W.prototype,"graphics",void 0),e([R(S(O,"analyses"))],W.prototype,"analyses",void 0),e([R({readOnly:!0,type:F})],W.prototype,"heightModelInfo",null),e([R({readOnly:!0})],W.prototype,"interacting",null),e([R({readOnly:!0})],W.prototype,"navigating",null),e([R({readOnly:!0,dependsOn:["fatalError","_isValid","_readyCycleForced","map","map.loaded?","width","height","spatialReference","_currentSpatialReference","defaultsFromMap.ready","typeSpecificPreconditionsReady"]})],W.prototype,"preconditionsReady",null),e([R({readOnly:!0})],W.prototype,"typeSpecificPreconditionsReady",void 0),e([R({type:s,readOnly:!0})],W.prototype,"layerViews",void 0),e([R({type:I})],W.prototype,"magnifier",void 0),e([R({value:null,type:t})],W.prototype,"map",null),e([R()],W.prototype,"padding",void 0),e([R({readOnly:!0})],W.prototype,"ready",void 0),e([R({type:L})],W.prototype,"spatialReference",null),e([R()],W.prototype,"spatialReferenceWarningDelay",void 0),e([R()],W.prototype,"stationary",null),e([R({readOnly:!0})],W.prototype,"supportsGround",void 0),e([R({type:i})],W.prototype,"timeExtent",void 0),e([R()],W.prototype,"tools",null),e([R()],W.prototype,"toolViewManager",void 0),e([R({readOnly:!0})],W.prototype,"type",void 0),e([R({type:Number})],W.prototype,"scale",void 0),e([R({readOnly:!0})],W.prototype,"updating",void 0),e([R({readOnly:!0})],W.prototype,"initialExtentRequired",void 0),e([R({readOnly:!0})],W.prototype,"initialExtent",null),e([R()],W.prototype,"cursor",null),e([R({readOnly:!0})],W.prototype,"input",void 0),e([R({type:U,nonNullable:!0})],W.prototype,"navigation",void 0),e([R()],W.prototype,"layerViewManager",void 0),e([R()],W.prototype,"analysisViewManager",void 0),e([R()],W.prototype,"width",void 0),e([R()],W.prototype,"height",void 0),e([R({readOnly:!0})],W.prototype,"resizing",void 0),e([R({value:null,readOnly:!0})],W.prototype,"size",null),e([R({readOnly:!0})],W.prototype,"suspended",void 0),e([R({readOnly:!0})],W.prototype,"viewEvents",void 0),e([R({readOnly:!0})],W.prototype,"persistableViewModels",void 0),e([R()],W.prototype,"_isValid",void 0),e([R()],W.prototype,"_readyCycleForced",void 0),e([R()],W.prototype,"_currentSpatialReference",void 0),W=P=e([_("esri.views.View")],W);const z=W;export{z as default};
|