MapView.js 25 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import s from"../core/Collection.js";import r from"../core/CollectionFlattener.js";import n from"../core/Error.js";import a from"../core/has.js";import{isIterable as o}from"../core/iteratorUtils.js";import l from"../core/Logger.js";import{isSome as p,unwrap as h,isNone as c}from"../core/maybe.js";import{throwIfAborted as d}from"../core/promiseUtils.js";import{watch as u,whenOnce as m,sync as g,syncAndInitial as f}from"../core/reactiveUtils.js";import{createScreenPoint as y}from"../core/screenUtils.js";import w from"../core/Warning.js";import{initialize as _}from"../core/workers/workers.js";import{property as v}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as V}from"../core/accessorSupport/decorators/subclass.js";import S from"../geometry/Extent.js";import j from"../geometry/Point.js";import{isLoaded as T,load as R,canProjectWithoutEngine as b,project as x}from"../geometry/projection.js";import{equals as M}from"../geometry/support/spatialReferenceUtils.js";import O from"../layers/support/TileInfo.js";import{BreakpointsOwner as k}from"./BreakpointsOwner.js";import{DOMContainer as z}from"./DOMContainer.js";import{PopupView as L}from"./PopupView.js";import P from"./View.js";import C from"./ViewAnimation.js";import E from"./2d/AnimationManager.js";import G from"./2d/FrameTask.js";import{layerView2DImporter as N}from"./2d/layerViewModuleImportUtils.js";import q from"./2d/MapViewConstraints.js";import D from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import A from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as F,setExtent as U,rotateTo as I,scaleTo as W,copy as B,create as H,extentToScale as $,resize as J,angleBetween as Q}from"./2d/viewpointUtils.js";import Z from"./2d/input/MapViewInputManager.js";import K from"./2d/layers/features/support/TileStore.js";import Y from"./2d/support/HighlightOptions.js";import{Timeline as X}from"./2d/support/Timeline.js";import ee from"./support/createScreenshotPlan.js";import{encode as te,encodeData as ie,getMaximumResolutionScale as se,getFormatAndQuality as re}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as ne,createScreenPointFromSupportedEvent as ae}from"./support/screenUtils.js";import{check as oe}from"./support/WebGLRequirements.js";import le from"./ui/2d/DefaultUI2D.js";import pe from"../webmap/background/ColorBackground.js";const he=l.getLogger("esri.views.MapView");let ce,de,ue,me,ge,fe;async function ye(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:r,Stage:n}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);de=e,ue=t,me=i,ge=s,fe=r,ce=n}const we=160;function _e(e){return e&&"esri.Viewpoint"===e.declaredClass}let ve=class extends(k(z(L(P)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new r({getCollections:()=>[this.basemapView?.baseLayerViews,this.layerViews,this.basemapView?.referenceLayerViews],getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!1,this.supportsGround=!1,this._stationaryTimer=null,this.frameTask=new G(this),this._pePromise=null,this.floors=new s,this.highlightOptions=new Y,this.inputManager=new Z({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new X,this.type="2d",this.ui=new le,this._pixelFormat={flipY:!0,premultipliedAlpha:!0},this.constraints=new q,this.padding={top:0,right:0,bottom:0,left:0},this.handles.add([u((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(we)}),g),this.on("resize",(e=>this._resizeHandler(e))),u((()=>this.animationManager?.animation),(e=>{this.animation=e}))]),_()}destroy(){this._set("preconditionsReady",!1),this._gotoTask=this.frameTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new K(this.featuresTilingScheme)}get initialExtentRequired(){const{scale:e,constraints:t,center:i,viewpoint:s,extent:r}=this;let n=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&this.map.initialViewProperties?.viewpoint)&&(!r&&(t?.effectiveLODs||(n=-1),(!i||0===e&&-1===n)&&(!s||!p(s.targetGeometry)||"extent"!==s.targetGeometry.type&&!s.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!T()||(this._pePromise||(this._pePromise=R().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=h(e.targetGeometry);return!!b(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask.requestFrame()),this.frameTask.animationInProgress=!1};e.when(i,i)}get background(){return this.get("map.initialViewProperties.background")||null}set background(e){void 0===e?this._clearOverride("background"):this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new j({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void he.error(new n("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;F(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(u((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),g),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void he.error(new n("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void he.error(new n("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;U(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;I(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;W(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){return!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)))}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new n("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):c(e.targetGeometry)&&(s=new n("mapview:invalid-viewpoint","geometry not defined"))}catch(a){s=new n("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:a})}if(s)return void he.error(s);this._scaleBeforeChangingSpatialReference=null;const r=new i({targetGeometry:new j,scale:0,rotation:0});B(r,t),this.constraints.constrain(r,this.state.paddedViewState.viewpoint),this.state.viewpoint=r,this.frameTask.requestFrame(),this._set("viewpoint",r)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;W(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),m((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=H(e,this);return this.animation.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));he.error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=ne(e)?ae(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let s=new Set,r=!1,n=null,a=null;t?.include?Te(t.include,je(this,(e=>s.add(e)),(e=>{n||(n=new Set),n.add(e)}),(e=>s.add(e)),(()=>r=!0))):(r=!0,s=new Set(this.allLayerViews)),t?.exclude&&Te(t.exclude,je(this,(e=>s.delete(e)),(e=>{a||(a=new Set),a.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&s.has(e))).reverse(),l=this.toMap(i);let h=[...r?this.graphicsView.hitTest(l).map((e=>({type:"graphic",graphic:e,layer:null,mapPoint:l}))):[],...await Promise.all(o.map((e=>e.hitTest(l,i))).toArray())].filter(p).flat().filter(p);return n&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||n.has(Se(e.graphic))))),a&&(h=h.filter((e=>!("graphic"in e)||!e.graphic||a.has(Se(e.graphic))))),{screenPoint:i,results:h}}async takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return te(i,{format:t.format,quality:t.quality,rotation:0,disableDecorations:!1},this._pixelFormat)}async _takeScreenshot(e){const t=this._createScreenshotPlan(e),i=await this._stage.takeScreenshot(t);return ie(i,this._pixelFormat)}_createScreenshotPlan(e){e=e||{};const t=this.supersampleScreenshotsEnabled?Math.min(4,se(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:s,quality:r}=re(e.format,e.quality);return ee(e,t,this.size,this.padding,s,r,i,e.rotation)}get test(){return{takeScreenshot:e=>this._takeScreenshot(e)}}toMap(e){if(!this.ready)return null;const t=ne(e)?ae(this,e):e,i=[0,0],[s,r]=this.state.toMap(i,[t.x,t.y]),n=this.spatialReference;return new j({x:s,y:r,spatialReference:n})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),y(i[0],i[1])}on(e,t,i,s){const r=this.inputManager&&this.viewEvents.on(e,t,i,s);return r||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){return this.map&&"initialViewProperties"in this.map&&this.map?.initialViewProperties?.spatialReference||this.defaultsFromMap?.spatialReference||null}hasLayerViewModule(e){return N.hasLayerViewModule(e)}importLayerView(e){return N.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(he.error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=oe(this.type);return a("safari")&&a("safari")<9&&(e=new n("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:a("safari")})),p(e)?(he.warn("#validate()",e.message),Promise.reject(e)):ye()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new C),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,r=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(this.animation=null,t.done||(t.stop(),this.frameTask.animationInProgress=!1)),e})),n=new Promise((e=>e(r)));return t.when().catch((()=>{s()&&n.cancel&&n.cancel()})),n}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(d(t),i!==this._gotoTask)throw new n("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,r)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<we&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){const{constraints:e,initialExtent:t,map:s,padding:r,size:n}=this;if(!e)return null;const a=s&&"initialViewProperties"in s&&s.initialViewProperties,o={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};e.effectiveLODs?-1!==o.zoom&&(o.scale=e.zoomToScale(o.zoom)):o.zoom=-1;let l=null,c=null,d=0;const u=o.viewpoint&&o.viewpoint.rotation,m=o.viewpoint&&o.viewpoint.targetGeometry;p(m)&&("extent"===m.type?l=m:"point"===m.type&&(c=m,d=o.viewpoint.scale));const g=o.extent||l||h(a?.viewpoint?.targetGeometry)?.extent||t,f=o.center||c||g?.center,y=o.scale||d||a?.viewpoint?.scale||g&&$(g,[n[0]-r.left-r.right,n[1]-r.top-r.bottom]),w=o.rotation||u||a?.viewpoint?.rotation||0;return f&&y?new i({targetGeometry:f,scale:y,rotation:w}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation,r=e.then((e=>{if(d(t),i!==this._gotoTask)throw new n("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,r)}_project(e,t){const i=e&&e.targetGeometry||e;if(!t)return e;if(!i)return null;if(t.imageCoordinateSystem||i.spatialReference?.imageCoordinateSystem)return e;if(M(t,i.spatialReference))return e;const s=x(i,t);if(!s)throw new n("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:i,spatialReference:t});return _e(e)?(e.targetGeometry=s,e):s}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],J(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,null),this.state.viewpoint=i}_startup(){this.timeline.begin("MapView Startup");const e=this._getDefaultViewpoint(),t=e.targetGeometry;try{this._project(e,this.spatialReference)}catch(o){he.warn(new w("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:t.toJSON(),spatialReference:this.spatialReference,error:o})),e.targetGeometry=this.defaultsFromMap.extent?.center||new j({x:0,y:0,spatialReference:this.spatialReference})}this.constraints?.fit(e),this._set("state",new D({padding:this._get("padding"),size:this.size,viewpoint:e})),this.graphics.owner=this;const i=new ce(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=i,this._magnifierView=new fe,this._magnifierView.magnifier=this.magnifier;const s=new me({view:this});this._set("labelManager",s);const r=new E({view:this});this._set("animationManager",r);const n=new ge({view:this,animationManager:r});this._set("mapViewNavigation",n),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),i.on("post-render",(()=>this._set("rendering",i.renderRequested))),i.on("will-render",(()=>this._set("rendering",i.renderRequested))),i.on("webgl-error",(e=>this.fatalError=e.error)),u((()=>this.stationary),(e=>i.stationary=e),f),u((()=>this.background),(e=>{i.background=e,this._magnifierView.background=e}),f),u((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),f),u((()=>this.renderingOptions),(e=>i.renderingOptions=e),f),u((()=>this.highlightOptions),(e=>i.highlightOptions=e),f),u((()=>this.state.id),(()=>i.state=this.state),f)],"map-view"),this._updateStageChildren();const a=this._resolveWhenReady;this._resolveWhenReady=[],a.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:r}=this.state.paddedViewState,n=new j({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",n),this._set("zoom",-1),this._set("rotation",s),this._set("scale",r),this._set("spatialReference",i),this._set("state",null),this.animation=null}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new A(O.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new de({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ue(e)});this.frameTask.graphicsView=t,this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),this.frameTask.graphicsView=null,e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(c(this._scaleBeforeChangingSpatialReference))this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[r,n]=t.center;let o=null;try{o=this._project(new j({x:r,y:n,spatialReference:t.spatialReference}),e)}catch(p){T()||he.warn(new w("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:o.toJSON(),spatialReference:e,error:p}))}o||(o=new j({x:0,y:0,spatialReference:e}));const l=F(new i({targetGeometry:new j,scale:0,rotation:0}),t.viewpoint,o);s.viewpoint=l;try{const i=20,r=[t.size[0]/2,t.size[1]/2],n=[r[0]+i,r[1]],o=t.toMap([0,0],n),{x:p,y:h}=this._project(new j({x:o[0],y:o[1],spatialReference:t.spatialReference}),e);o[0]=p,o[1]=h,s.toScreen(o,o);const c=Q(r,o,n),d=Math.hypot(o[0]-r[0],o[1]-r[1])/i;!Number.isFinite(d)||Math.abs(d)>4?(l.rotation=0,l.targetGeometry=new j({x:0,y:0,spatialReference:e})):(l.scale*=d,l.scale>a("mapview-srswitch-adjust-rotation-scale-threshold")?l.rotation=0:l.rotation+=Number.isFinite(c)?c:0)}catch{}this._get("constraints").constrain(l,null),this._get("state").viewpoint=l,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};ve.type="2d",e([v({readOnly:!0})],ve.prototype,"animationManager",void 0),e([v({constructOnly:!0})],ve.prototype,"deactivatedWebGLExtensions",void 0),e([v({constructOnly:!0})],ve.prototype,"debugWebGLExtensions",void 0),e([v({readOnly:!0})],ve.prototype,"featuresTilingScheme",void 0),e([v({readOnly:!0})],ve.prototype,"fullOpacity",void 0),e([v({readOnly:!0})],ve.prototype,"graphicsTileStore",null),e([v()],ve.prototype,"graphicsView",void 0),e([v({readOnly:!0})],ve.prototype,"state",void 0),e([v()],ve.prototype,"initialExtentRequired",null),e([v()],ve.prototype,"labelManager",void 0),e([v({readOnly:!0})],ve.prototype,"resourceManager",null),e([v({readOnly:!0})],ve.prototype,"textureManager",null),e([v({readOnly:!0})],ve.prototype,"mapViewNavigation",void 0),e([v({constructOnly:!0})],ve.prototype,"renderCanvas",void 0),e([v()],ve.prototype,"renderingOptions",void 0),e([v({readOnly:!0})],ve.prototype,"rendering",void 0),e([v({constructOnly:!0})],ve.prototype,"supersampleScreenshotsEnabled",void 0),e([v({readOnly:!0})],ve.prototype,"supportsGround",void 0),e([v()],ve.prototype,"_stationaryTimer",void 0),e([v()],ve.prototype,"_defaultsFromMapSettings",null),e([v()],ve.prototype,"_pePromise",void 0),e([v({readOnly:!0})],ve.prototype,"typeSpecificPreconditionsReady",null),e([v()],ve.prototype,"animation",null),e([v({type:pe})],ve.prototype,"background",null),e([v({value:null,type:j,dependsOn:["state.id","ready"]})],ve.prototype,"center",null),e([v({type:q})],ve.prototype,"constraints",null),e([v({value:null,type:S,dependsOn:["state.id","ready"]})],ve.prototype,"extent",null),e([v()],ve.prototype,"floors",void 0),e([v({type:Y})],ve.prototype,"highlightOptions",void 0),e([v({readOnly:!0})],ve.prototype,"inputManager",void 0),e([v()],ve.prototype,"map",void 0),e([v({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],ve.prototype,"padding",null),e([v()],ve.prototype,"resizeAlign",void 0),e([v({readOnly:!0,dependsOn:["state.id"]})],ve.prototype,"resolution",null),e([v({value:0,type:Number,dependsOn:["state.id","ready"]})],ve.prototype,"rotation",null),e([v({value:0,type:Number,dependsOn:["state.id","ready"]})],ve.prototype,"scale",null),e([v({constructOnly:!0})],ve.prototype,"spatialReferenceLocked",void 0),e([v()],ve.prototype,"stationary",null),e([v({type:X,readOnly:!0})],ve.prototype,"timeline",void 0),e([v({readOnly:!0})],ve.prototype,"type",void 0),e([v({readOnly:!0})],ve.prototype,"updating",null),e([v({value:null,type:i,dependsOn:["state.id","ready"]})],ve.prototype,"viewpoint",null),e([v({value:-1,dependsOn:["state.id","ready"]})],ve.prototype,"zoom",null),e([v({type:Boolean})],ve.prototype,"navigating",null),e([v({type:le})],ve.prototype,"ui",void 0),ve=e([V("esri.views.MapView")],ve);const Ve=ve;function Se(e){const t=e.getObjectId();return t?`${e.layer?.uid??e.sourceLayer?.uid??"MapView"}/${t}`:`"MapView/${e.uid}`}function je(e,i,s,r,n){return a=>{if(a instanceof t){if(a.layer===e)n?.();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&r?.(t)}s(Se(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Te(e,t){if(e)if(o(e))for(const i of e)if(o(i))for(const e of i)t(e);else t(i);else t(e)}export{Ve as default};