@arcgis/map-components
Version:
ArcGIS Map Components
2 lines • 6.81 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import a from"./HFRXDFTO.js";import"./PC4PAQXQ.js";import{a as C}from"./HZFVK34O.js";import"./AKBXFBDL.js";import"./LMBRORN7.js";import"./PBSJQPB2.js";import{M as f,N as v,O as w,U as L,a as g,b as _,p as y,z as u}from"./WUJCCZQC.js";import"./3TTFCHAA.js";export default $arcgis.t(([{property:c,subclass:M},b,,G,{watch:m},{rotateDimensions:P,registerPanConstraint:I},z,,O,{b:d}])=>{var x=g`:host{height:100%;--arcgis-view-color-focus: none}`,A=Object.defineProperty,E=Object.getOwnPropertyDescriptor,h=(t,e,r,i)=>{for(var a=i>1?void 0:i?E(e,r):e,s=t.length-1,o;s>=0;s--)(o=t[s])&&(a=(i?o(e,r,a):o(a))||a);return i&&a&&A(e,r,a),a},n=class extends b{constructor(t){super(t),this.autoLoad=!1}static isNonPanoramicMedia(t){return!!t&&typeof t=="object"&&"declaredClass"in t&&typeof t.declaredClass=="string"&&t.declaredClass==="components.oriented-imagery-viewer.support.NonPanoramicMedia"}destroy(){this._cache?.destroy(),this._cache=void 0}get layer(){return this._cache}get size(){if(!this._cache||this._cache.destroyed||this._cache.loadError||!this._cache.serviceRasterInfo)return;let{serviceRasterInfo:t}=this._cache;return[t.width,t.height]}async load(t){if(this._cache&&!this._cache.destroyed)return await this._cache.load(t),{layer:this._cache,size:this.size};let{url:e,customParameters:r}=this,i=this.datasetFormat;if(!e)throw new Error("URL is required to load NonPanoramicMedia.");if(!i){let o=await import("./3A4SIMPX.js").then(m=>m.default);if(d(t),i=o.guessExtensionFromURI(e),!i){try{i=await o.getDatasetFormat(e)}catch{y("warn",this,"Failed to determine dataset format from URL or response headers."),i="UNKNOWN FORMAT"}d(t)}}this.datasetFormat=i;let a=(await $arcgis.t(m=>m[0],"layers/ImageryTileLayer")).default;d(t);let s=new a({url:e,ioConfig:{skipExtensions:["aux.xml","jgw"],skipMapInfo:!0,datasetFormat:i},customParameters:r??void 0});return await s.load(t),d(t),this._cache=s,{layer:this._cache,size:this.size}}};h([c()],n.prototype,"_cache",2);h([c()],n.prototype,"autoLoad",2);h([c()],n.prototype,"customParameters",2);h([c()],n.prototype,"datasetFormat",2);h([c()],n.prototype,"url",2);h([c()],n.prototype,"layer",1);h([c()],n.prototype,"size",1);n=h([M("components.oriented-imagery-viewer.support.NonPanoramicMedia")],n);function F(t,e,r,i,a){let{width:s,height:o}=P(t,e,a);return Math.max(s/r,o/i)}var N=96,$=39.37,R=$*N;function j(t){let e=R*.25,r=R*t,i=[],a=r;for(;a>e;)i.push(a),a*=.5;i.push(e);let{lods:s}=z.create({scales:i});return{minScale:r,lods:s}}var l=class extends u{get graphics(){return this._graphicsLayer?.graphics}_ensureGraphicsLayer(){(!this._graphicsLayer||this._graphicsLayer.destroyed)&&(this._graphicsLayer=new O({title:"Overlays",listMode:"hide",visible:!0,blendMode:"source-atop"}))}hostLoaded(){this._ensureGraphicsLayer(),this.component.manager.onLifecycle(()=>[m(()=>this.component?.map,(e,r)=>{r?.layers.remove(this._graphicsLayer),e&&e?.layers.add(this._graphicsLayer)},{initial:!0,sync:!0}),m(()=>this.component?.map?.allLayers.length,e=>{e&&this.component?.map?.layers.reorder(this._graphicsLayer,e-1)},{initial:!0,sync:!0})])}addGraphic(e){this._graphicsLayer.add(e)}addGraphics(e){this._graphicsLayer.addMany(e)}removeGraphic(e){this._graphicsLayer?.destroyed||this._graphicsLayer.remove(e)}removeGraphics(e){this._graphicsLayer?.destroyed||this._graphicsLayer.removeMany(e)}clearGraphics(){this._graphicsLayer?.destroyed||this._graphicsLayer.removeAll()}destroy(){this._graphicsLayer?.destroy()}},p=class extends w{constructor(){super(...arguments),this._messages=C(),this._graphicsController=new l(this),this._imageChanged=!1,this._internalMap=f(),this._loading=!1,this.hideHeader=!1,this.hideLoader=!1,this.hideZoomControls=!1,this.messageOverrides=this._messages._overrides,this.rotation=0}static{this.properties={_imageChanged:16,_internalMap:16,_image:16,_loading:16,_media:16,hideHeader:5,hideLoader:5,hideZoomControls:5,messageOverrides:0,media:0,rotation:9}}static{this.styles=[x]}get imageRenderer(){return this._internalMap?.value?.view}get map(){return this.imageRenderer?.map}get media(){return this._media}set media(e){if(!e){this._mediaAbortController?.abort(),this._media=void 0,this._clearImage();return}this._media=e instanceof n?e:new n(e)}addGraphic(e){this._graphicsController.addGraphic(e)}addGraphics(e){this._graphicsController.addGraphics(e)}clearGraphics(){this._graphicsController.clearGraphics()}async mediaOnLoad(){return this._mediaPromise&&await this._mediaPromise,this._media}removeGraphic(e){this._graphicsController.removeGraphic(e)}removeGraphics(e){this._graphicsController.removeGraphics(e)}loaded(){this.manager.onLifecycle(()=>[this._createResizeConstraint(),this._createRotationHandler(),this._createPanConstraint(),m(()=>this._media,e=>{this._mediaAbortController?.abort(),e&&(this._mediaAbortController=new AbortController,this._mediaPromise=this._loadMediaInternal(e,this._mediaAbortController))},{initial:!0,sync:!0})])}_createPanConstraint(){return m(()=>({image:this._image,imageRenderer:this.imageRenderer}),({image:e,imageRenderer:r})=>{!e||!r?.ready||I(r,e)},{sync:!0,initial:!0})}_createResizeConstraint(){return m(()=>{if(!this.imageRenderer?.ready||!this._image)return;let{width:e,height:r}=this._image.serviceRasterInfo,{width:i,height:a,rotation:s}=this.imageRenderer;return F(e,r,i,a,s)},e=>{if(!e||!this.imageRenderer)return;let{constraints:r,scale:i}=this.imageRenderer,a=r.minScale,{lods:s,minScale:o}=j(e);r.set({minScale:o,lods:s}),this.imageRenderer.scale=this._imageChanged||Math.abs(i-a)<=1e-6?o:i,this._imageChanged=!1},{sync:!0,initial:!0})}_createRotationHandler(){return m(()=>this.rotation,e=>{this.imageRenderer&&(this.imageRenderer.constraints.rotationEnabled=!0,this.imageRenderer.rotation=e,this.imageRenderer.constraints.rotationEnabled=!1)},{sync:!0,initial:!0})}_clearImage(){this._image?.destroy(),this._image=void 0}async _loadMediaInternal(e,r){if(this._loading=!0,this._clearImage(),!e)throw new Error("No media provided");let{layer:i}=await e.load(r).finally(()=>{this._loading=!1});d(r),this._imageChanged=!0,this._image=i,this.imageRenderer?.map?.layers.add(this._image)}render(){return _`<calcite-panel .loading=${this.hideLoader?void 0:this._loading} .heading=${this.hideHeader?void 0:this._messages.title}><arcgis-map hide-attribution .spatialReference=${G.WebMercator} ${v(this._internalMap)}><arcgis-zoom .hidden=${this.hideZoomControls} slot=top-left></arcgis-zoom></arcgis-map></calcite-panel>`}};L("arcgis-oriented-imagery-viewer-image-viewer",p);return p},"core/accessorSupport/decorators","core/Accessor","views/MapView","geometry/SpatialReference","core/reactiveUtils","applications/Components/OrientedImageryViewer/ImageViewer/utils","layers/support/TileInfo","Graphic","layers/GraphicsLayer",a)