You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
4.3 KiB
12 lines
4.3 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../../chunks/tslib.es6 ../../Basemap ../../core/Collection ../../core/Loadable ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/accessorSupport/decorators/cast ../../core/RandomLCG ../../core/has ../../core/accessorSupport/decorators/subclass ../../geometry/projection ../../geometry/support/spatialReferenceUtils ../../support/basemapUtils ./support/basemapCompatibilityUtils ./support/BasemapGalleryItem ./support/LocalBasemapsSource ./support/PortalBasemapsSource".split(" "), |
|
function(g,w,l,p,m,h,x,d,B,y,n,q,z,r,t,A,k){const u=l.ofType(t);d=class extends p{constructor(a){super(a);this._loadingProjectionEngine=!1;this.items=new u;this.source=new k;this.view=null}initialize(){const a=()=>this._recreateItems();this.addHandles([m.watch(()=>"ready"===this.state?this.compatibilityFunction:null,()=>this._updateItems()),m.on(()=>this.source?.basemaps,"change",a,{onListenerAdd:a}),m.when(()=>this.view,()=>{this.source instanceof k&&(this.source.viewType=this.view?.type)},{once:!0})])}destroy(){const a= |
|
this.source.basemaps.find(b=>b===this.activeBasemap);a&&this.source.basemaps.remove(a);this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(a){const b=this.view;if(b?.map){var e="string"===typeof a?w.fromId(a):a;if(e&&b.ready){var c=e.spatialReference||this.items?.find(f=>this.basemapEquals(e,f.basemap))?.spatialReference;if(c&&"spatialReferenceLocked"in b&&!b.spatialReferenceLocked){const f=b.spatialReference;null==c||q.equals(f,c)||n.canProjectWithoutEngine(b.spatialReference, |
|
c)||n.isLoaded()?(b.map.basemap=e,this._clearOverride("activeBasemap"),null==c||q.equals(b.spatialReference,c)||(b.spatialReference=c)):(this._override("activeBasemap",e),this._loadingProjectionEngine=!0,n.load().then(()=>{this._get("activeBasemap")===a&&(b.map.basemap=a,b.spatialReference=c,this._clearOverride("activeBasemap"))},()=>{}).then(()=>{this._loadingProjectionEngine=!1}))}else b.map.basemap=e,this._clearOverride("activeBasemap")}else b.map.basemap=e,this._clearOverride("activeBasemap")}}get activeBasemapIndex(){const {state:a, |
|
activeBasemap:b}=this;return"ready"!==a?-1:this._findBasemapIndex(b)}get compatibilityFunction(){return"3d"===this.view?.type?r.default3DCompatibility:r.default2DCompatibility}set compatibilityFunction(a){this._overrideIfSome("compatibilityFunction",a)}castSource(a){return Array.isArray(a)||l.isCollection(a)?new A({basemaps:Array.isArray(a)?new l(a):a}):a&&"esri.portal.Portal"===a.declaredClass?new k({portal:a}):!a||a instanceof k||!a.portal&&!a.query?a&&"basemaps"in a&&"state"in a&&"refresh"in a? |
|
a:null:new k(a)}get state(){return this.view?.ready&&this.source?this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(a,b){return z.contentEquals(a,b)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(a){this.addResolvingPromise(p.isLoadable(this.source)?this.source.load(a):null);return Promise.resolve(this)}_findBasemapIndex(a){const {items:b}=this,e=b.findIndex(c=>c.basemap===a);return-1===e?b.findIndex(c=>this.basemapEquals(c.basemap,a)):e}_recreateItems(){var a= |
|
this.source?.basemaps??[];const {view:b,compatibilityFunction:e}=this,c=new Map(this.items.map(f=>[f.basemap,f]));a=a.map(f=>{const v=c.get(f);return v?(c.delete(f),v):new t({basemap:f,compatibilityFunction:e,view:b})});this.items.removeAll();this.items.addMany(a);c.forEach(f=>f.destroy())}_updateItems(){for(const a of this.items)a.compatibilityFunction=this.compatibilityFunction,a.view=this.view}};g.__decorate([h.property()],d.prototype,"_loadingProjectionEngine",void 0);g.__decorate([h.property()], |
|
d.prototype,"activeBasemap",null);g.__decorate([h.property({readOnly:!0})],d.prototype,"activeBasemapIndex",null);g.__decorate([h.property()],d.prototype,"compatibilityFunction",null);g.__decorate([h.property({readOnly:!0,type:u})],d.prototype,"items",void 0);g.__decorate([h.property()],d.prototype,"source",void 0);g.__decorate([x.cast("source")],d.prototype,"castSource",null);g.__decorate([h.property({readOnly:!0})],d.prototype,"state",null);g.__decorate([h.property()],d.prototype,"view",void 0); |
|
return d=g.__decorate([y.subclass("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],d)}); |