Custom Gis Application with Arcgis Javascript API with modern layouting
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.
 
 

35 lines
16 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("require ../chunks/tslib.es6 ../config ../kernel ../request ../core/Error ../core/JSONSupport ../core/Loadable ../core/maybe ../core/promiseUtils ../core/accessorSupport/decorators/property ../core/accessorSupport/ensureType ../core/RandomLCG ../core/has ../core/accessorSupport/decorators/reader ../core/accessorSupport/decorators/subclass ../geometry/Extent ../intl/locale ./portalDefault ./PortalGroup ./PortalQueryParams ./PortalQueryResult ./PortalUser ../support/apiKeyUtils".split(" "),function(y,
c,u,q,F,z,b,G,v,p,d,H,Q,R,r,I,J,A,K,L,w,M,C,N){function O(a){const e=q.id;return()=>{const f=a.deref();f&&e.findCredential(f.restUrl)&&f.signIn().catch(()=>{})}}const B=a=>Object.freeze(Object.defineProperty({__proto__:null,default:a},Symbol.toStringTag,{value:"Module"}));var l;let x;const D={PortalGroup:()=>Promise.resolve({default:L}),PortalItem:()=>new Promise((a,e)=>y(["./PortalItem"],f=>a(B(f)),e)),PortalUser:()=>Promise.resolve({default:C})};b=l=class extends b.JSONSupportMixin(G){constructor(a){super(a);
this.access=this._esriIdCredentialCreateHandle=null;this.allSSL=!1;this.authMode="auto";this.bingKey=this.basemapGalleryGroupQuery3D=this.basemapGalleryGroupQuery=this.authorizedCrossOriginDomains=null;this.canProvisionDirectPurchase=this.canListPreProvisionedItems=this.canListData=this.canListApps=!1;this.canSearchPublic=!0;this.canSignInIDP=this.canSignInArcGIS=this.canSharePublic=this.canShareBingPublic=!1;this.colorSetsGroupQuery=null;this.commentsEnabled=!1;this.livingAtlasGroupQuery=this.layoutGroupQuery=
this.galleryTemplatesGroupQuery=this.featuredItemsGroupQuery=this.featuredGroups=this.eueiEnabled=this.devBasemapGalleryGroupQuery=this.description=this.defaultVectorBasemap=this.defaultExtent=this.defaultDevBasemap=this.defaultBasemap=this.customBaseUrl=this.culture=this.created=null;this.hasCategorySchema=!1;this.ipCntryCode=this.id=this.httpsPort=this.httpPort=this.homePageFeaturedContentCount=this.homePageFeaturedContent=this.helperServices=null;this.isReadOnly=this.isPortal=!1;this.region=this.portalProperties=
this.portalMode=this.portalHostname=this.name=this.modified=this.maxTokenExpirationMinutes=this.layerTemplatesGroupQuery=null;this.recycleBinEnabled=!1;this.rotatorPanels=null;this.showHomePageDescription=!1;this.sourceJSON=null;this.supportsHostedServices=!1;this.units=this.templatesGroupQuery=this.symbolSetsGroupQuery=null;this.url=u.portalUrl;this.user=this.urlKey=null;this.use3dBasemaps=!0;this.useVectorBasemaps=this.useStandardizedQuery=!1;this.vectorBasemapGalleryGroupQuery=null}normalizeCtorArgs(a){return"string"===
typeof a?{url:a}:a}destroy(){E.unregister(this);this.defaultBasemap=v.destroyMaybe(this.defaultBasemap);this.defaultDevBasemap=v.destroyMaybe(this.defaultDevBasemap);this.defaultVectorBasemap=v.destroyMaybe(this.defaultVectorBasemap);this._esriIdCredentialCreateHandle=v.removeMaybe(this._esriIdCredentialCreateHandle)}readAuthorizedCrossOriginDomains(a){if(a)for(const e of a)u.request.trustedServers.includes(e)||u.request.trustedServers.push(e);return a}readDefaultBasemap(a){return this._readBasemap(a)}readDefaultDevBasemap(a){return this._readBasemap(a)}readDefaultVectorBasemap(a){return this._readBasemap(a)}get extraQuery(){const a=
!this.user?.orgId||this.canSearchPublic;return this.id&&!a?` AND orgid:${this.id}`:null}get isOrganization(){return!!this.access}get itemPageUrl(){return this.url?`${this.url}/home/item.html`:null}get restUrl(){let a=this.url;if(a){const e=a.indexOf("/sharing");a=0<e?a.substring(0,e):this.url.replace(/\/+$/,"");a+="/sharing/rest"}return a}get thumbnailUrl(){const a=this.restUrl,e=this.thumbnail;return a&&e?this._normalizeSSL(a+"/portals/self/resources/"+e):null}readUrlKey(a){return a?a.toLowerCase():
a}readUser(a){let e=null;a&&(e=C.fromJSON(a),e.portal=this);return e}load(a){const e=(new Promise((f,g)=>y(["../Basemap"],h=>f(B(h)),g))).then(({default:f})=>{p.throwIfAborted(a);x=f}).then(()=>this.sourceJSON?this.sourceJSON:this.fetchSelf(this.authMode,!1,a)).then(f=>{if(q.id){const g=q.id;this.credential=g.findCredential(this.restUrl);this.credential||this.authMode!==l.AUTH_MODE_AUTO&&this.authMode!==l.AUTH_MODE_NO_PROMPT||(this._esriIdCredentialCreateHandle?.remove(),this._esriIdCredentialCreateHandle=
g.on("credential-create",O(new WeakRef(this))),E.register(this,this._esriIdCredentialCreateHandle,this))}this.sourceJSON=f;this.read(f)});this.addResolvingPromise(e);return Promise.resolve(this)}async createElevationLayers(){await this.load();const a=this._getHelperService("defaultElevationLayers"),e=(await new Promise((f,g)=>y(["../layers/ElevationLayer"],h=>f(B(h)),g))).default;return a?a.map(f=>new e({id:f.id,url:f.url})):[]}async fetchBasemaps(a,e){const f=await this._fetchBasemaps(a,e);!0===
e?.include3d&&!1!==this.use3dBasemaps&&(a=await this._fetchBasemaps3D(a,e),f.unshift(...a));return f}fetchCategorySchema(a){return this.hasCategorySchema?this.request(this.restUrl+"/portals/self/categorySchema",a).then(e=>e.categorySchema):p.isAborted(a)?Promise.reject(p.createAbortError()):Promise.resolve([])}fetchFeaturedGroups(a){const e=this.featuredGroups,f=new w({num:100,sortField:"title"});if(e?.length){const g=[];for(const h of e)g.push(`(title:"${h.title}" AND owner:${h.owner})`);f.query=
g.join(" OR ");return this.queryGroups(f,a).then(h=>h.results)}return p.isAborted(a)?Promise.reject(p.createAbortError()):Promise.resolve([])}fetchRegions(a){const e=this.user?.culture||this.culture||A.getLocale();return this.request(this.restUrl+"/portals/regions",{...a,query:{culture:e}})}fetchSettings(a){const e=this.user?.culture||this.culture||A.getLocale();return this.request(this.restUrl+"/portals/self/settings",{...a,query:{culture:e}})}static getDefault(){return K.ensureDefaultPortalInstance(()=>
new l)}queryGroups(a,e){return this.queryPortal("/community/groups",a,"PortalGroup",e)}queryItems(a,e){return this.queryPortal("/search",a,"PortalItem",e)}queryUsers(a,e){a.sortField||(a.sortField="username");return this.queryPortal("/community/users",a,"PortalUser",e)}fetchSelf(a=this.authMode,e=!1,f){const g=this.restUrl+"/portals/self";a={authMode:a,query:{culture:A.getLocale().toLowerCase()},withCredentials:!0,...f};"auto"===a.authMode&&(a.authMode="no-prompt");e&&(a.query.default=!0);return this.request(g,
a)}queryPortal(a,e,f,g){const h=H.ensureType(w,e),k=t=>this.request(this.restUrl+a,{...h.toRequestOptions(this),...g}).then(m=>{const n=h.clone();n.start=m.nextStart;return new M({nextQueryParams:n,queryParams:h,total:m.total,results:l._resultsToTypedArray(t,{portal:this},m,g)})}).then(m=>Promise.all(m.results.map(n=>"function"===typeof n.when?n.when():m)).then(()=>m,n=>{p.throwIfAbortError(n);return m}));return f&&D[f]?D[f]().then(({default:t})=>{p.throwIfAborted(g);return k(t)}):k()}signIn(){if(this.authMode===
l.AUTH_MODE_ANONYMOUS||this.authMode===l.AUTH_MODE_NO_PROMPT&&!q.id)return Promise.reject(new z("portal:invalid-auth-mode",`Current "authMode"' is "${this.authMode}"`));if("failed"===this.loadStatus)return Promise.reject(this.loadError);const a=e=>Promise.resolve().then(()=>{if("not-loaded"===this.loadStatus)return e||(this.authMode="immediate"),this.load().then(()=>null);if("loading"===this.loadStatus)return this.load().then(()=>{if(this.credential)return null;this.credential=e;return this.fetchSelf("immediate")});
if(this.user&&this.credential===e)return null;this.credential=e;return this.fetchSelf("immediate")}).then(f=>{f&&(this.sourceJSON=f,this.read(f))});return q.id?q.id.getCredential(this.restUrl,{prompt:this.authMode!==l.AUTH_MODE_NO_PROMPT}).then(e=>a(e)):a(this.credential)}normalizeUrl(a){const e=this.credential?.token;return this._normalizeSSL(e?a+(a.includes("?")?"\x26":"?")+"token\x3d"+e:a)}requestToTypedArray(a,e,f){return this.request(a,e).then(g=>{const h=l._resultsToTypedArray(f,{portal:this},
g);return Promise.all(h.map(k=>"function"===typeof k.when?k.when():g)).then(()=>h,()=>h)})}request(a,e={}){var f={f:"json",...e.query};const {authMode:g=this.authMode===l.AUTH_MODE_ANONYMOUS||this.authMode===l.AUTH_MODE_NO_PROMPT?this.authMode:"auto",body:h=null,cacheBust:k=!1,method:t="auto",responseType:m="json",signal:n}=e;f={authMode:g,body:h,cacheBust:k,method:t,query:f,responseType:m,timeout:0,signal:n};e.withCredentials&&(f.withCredentials=!0);return F(this._normalizeSSL(a),f).then(P=>P.data)}toJSON(){throw new z("internal:not-yet-implemented",
"Portal.toJSON is not yet implemented");}static fromJSON(a){if(!a)return null;if(a.declaredClass)throw Error("JSON object is already hydrated");return new l({sourceJSON:a})}_getHelperService(a){const e=this.helperServices&&this.helperServices[a];if(!e)throw new z("portal:service-not-found",`The \`helperServices\` do not include an entry named "${a}"`);return e}async _fetchBasemaps(a,e){const f=new w;f.query=a||(u.apiKey&&N.supportsApiKey(this.url)?this.devBasemapGalleryGroupQuery:this.useVectorBasemaps?
this.vectorBasemapGalleryGroupQuery:this.basemapGalleryGroupQuery);f.disableExtraQuery=!0;a=await this.queryGroups(f,e);if(!a.total)return[];a=a.results[0];f.num=100;f.query='type:"Web Map" -type:"Web Application"';f.sortField=a.sortField||"name";f.sortOrder=a.sortOrder||"desc";e=await a.queryItems(f,e);return e.total?e.results.filter(g=>"Web Map"===g.type).map(g=>new x({portalItem:g})):[]}async _fetchBasemaps3D(a,e){a=a||this.basemapGalleryGroupQuery3D;if(!a)return[];a=new w({query:a,disableExtraQuery:!0});
var f=await this.queryGroups(a,e);if(!f.total)return[];f=f.results[0];a.num=100;a.query='type:"Web Scene"';a.sortField=f.sortField||"name";a.sortOrder=f.sortOrder||"desc";e=await f.queryItems(a,e);return e.total?e.results.filter(g=>"Web Scene"===g.type).map(g=>new x({portalItem:g})):[]}_normalizeSSL(a){return a.replace(/^http:/i,"https:").replace(":7080",":7443")}_readBasemap(a){return a?(a=x.fromJSON(a),a.portalItem={portal:this},a):null}static _resultsToTypedArray(a,e,f,g){if(f){const h=null!=g?
g.signal:null;f=f.listings||f.notifications||f.userInvitations||f.tags||f.items||f.groups||f.comments||f.provisions||f.results||f.relatedItems||f;if(a||e)f=f.map(k=>{k=Object.assign(a?a.fromJSON(k):k,e);"function"===typeof k.load&&k.load(h);return k})}else f=[];return f}};b.AUTH_MODE_ANONYMOUS="anonymous";b.AUTH_MODE_AUTO="auto";b.AUTH_MODE_IMMEDIATE="immediate";b.AUTH_MODE_NO_PROMPT="no-prompt";c.__decorate([d.property()],b.prototype,"access",void 0);c.__decorate([d.property()],b.prototype,"allSSL",
void 0);c.__decorate([d.property()],b.prototype,"authMode",void 0);c.__decorate([d.property()],b.prototype,"authorizedCrossOriginDomains",void 0);c.__decorate([r.reader("authorizedCrossOriginDomains")],b.prototype,"readAuthorizedCrossOriginDomains",null);c.__decorate([d.property()],b.prototype,"basemapGalleryGroupQuery",void 0);c.__decorate([d.property({json:{name:"3DBasemapGalleryGroupQuery"}})],b.prototype,"basemapGalleryGroupQuery3D",void 0);c.__decorate([d.property()],b.prototype,"bingKey",void 0);
c.__decorate([d.property()],b.prototype,"canListApps",void 0);c.__decorate([d.property()],b.prototype,"canListData",void 0);c.__decorate([d.property()],b.prototype,"canListPreProvisionedItems",void 0);c.__decorate([d.property()],b.prototype,"canProvisionDirectPurchase",void 0);c.__decorate([d.property()],b.prototype,"canSearchPublic",void 0);c.__decorate([d.property()],b.prototype,"canShareBingPublic",void 0);c.__decorate([d.property()],b.prototype,"canSharePublic",void 0);c.__decorate([d.property()],
b.prototype,"canSignInArcGIS",void 0);c.__decorate([d.property()],b.prototype,"canSignInIDP",void 0);c.__decorate([d.property()],b.prototype,"colorSetsGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"commentsEnabled",void 0);c.__decorate([d.property({type:Date})],b.prototype,"created",void 0);c.__decorate([d.property()],b.prototype,"credential",void 0);c.__decorate([d.property()],b.prototype,"culture",void 0);c.__decorate([d.property()],b.prototype,"currentVersion",void 0);c.__decorate([d.property()],
b.prototype,"customBaseUrl",void 0);c.__decorate([d.property()],b.prototype,"defaultBasemap",void 0);c.__decorate([r.reader("defaultBasemap")],b.prototype,"readDefaultBasemap",null);c.__decorate([d.property()],b.prototype,"defaultDevBasemap",void 0);c.__decorate([r.reader("defaultDevBasemap")],b.prototype,"readDefaultDevBasemap",null);c.__decorate([d.property({type:J})],b.prototype,"defaultExtent",void 0);c.__decorate([d.property()],b.prototype,"defaultVectorBasemap",void 0);c.__decorate([r.reader("defaultVectorBasemap")],
b.prototype,"readDefaultVectorBasemap",null);c.__decorate([d.property()],b.prototype,"description",void 0);c.__decorate([d.property()],b.prototype,"devBasemapGalleryGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"eueiEnabled",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"extraQuery",null);c.__decorate([d.property()],b.prototype,"featuredGroups",void 0);c.__decorate([d.property()],b.prototype,"featuredItemsGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"galleryTemplatesGroupQuery",
void 0);c.__decorate([d.property()],b.prototype,"layoutGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"livingAtlasGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"hasCategorySchema",void 0);c.__decorate([d.property()],b.prototype,"helpBase",void 0);c.__decorate([d.property()],b.prototype,"helperServices",void 0);c.__decorate([d.property()],b.prototype,"helpMap",void 0);c.__decorate([d.property()],b.prototype,"homePageFeaturedContent",void 0);c.__decorate([d.property()],b.prototype,
"homePageFeaturedContentCount",void 0);c.__decorate([d.property()],b.prototype,"httpPort",void 0);c.__decorate([d.property()],b.prototype,"httpsPort",void 0);c.__decorate([d.property()],b.prototype,"id",void 0);c.__decorate([d.property()],b.prototype,"ipCntryCode",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"isOrganization",null);c.__decorate([d.property()],b.prototype,"isPortal",void 0);c.__decorate([d.property()],b.prototype,"isReadOnly",void 0);c.__decorate([d.property({readOnly:!0})],
b.prototype,"itemPageUrl",null);c.__decorate([d.property()],b.prototype,"layerTemplatesGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"maxTokenExpirationMinutes",void 0);c.__decorate([d.property({type:Date})],b.prototype,"modified",void 0);c.__decorate([d.property()],b.prototype,"name",void 0);c.__decorate([d.property()],b.prototype,"portalHostname",void 0);c.__decorate([d.property()],b.prototype,"portalMode",void 0);c.__decorate([d.property()],b.prototype,"portalProperties",void 0);
c.__decorate([d.property()],b.prototype,"region",void 0);c.__decorate([d.property()],b.prototype,"recycleBinEnabled",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"restUrl",null);c.__decorate([d.property()],b.prototype,"rotatorPanels",void 0);c.__decorate([d.property()],b.prototype,"showHomePageDescription",void 0);c.__decorate([d.property()],b.prototype,"sourceJSON",void 0);c.__decorate([d.property()],b.prototype,"staticImagesUrl",void 0);c.__decorate([d.property({json:{name:"2DStylesGroupQuery"}})],
b.prototype,"stylesGroupQuery2d",void 0);c.__decorate([d.property({json:{name:"stylesGroupQuery"}})],b.prototype,"stylesGroupQuery3d",void 0);c.__decorate([d.property()],b.prototype,"supportsHostedServices",void 0);c.__decorate([d.property()],b.prototype,"symbolSetsGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"templatesGroupQuery",void 0);c.__decorate([d.property()],b.prototype,"thumbnail",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"thumbnailUrl",null);c.__decorate([d.property()],
b.prototype,"units",void 0);c.__decorate([d.property()],b.prototype,"url",void 0);c.__decorate([d.property()],b.prototype,"urlKey",void 0);c.__decorate([r.reader("urlKey")],b.prototype,"readUrlKey",null);c.__decorate([d.property()],b.prototype,"user",void 0);c.__decorate([r.reader("user")],b.prototype,"readUser",null);c.__decorate([d.property()],b.prototype,"use3dBasemaps",void 0);c.__decorate([d.property()],b.prototype,"useStandardizedQuery",void 0);c.__decorate([d.property()],b.prototype,"useVectorBasemaps",
void 0);c.__decorate([d.property()],b.prototype,"vectorBasemapGalleryGroupQuery",void 0);c=b=l=c.__decorate([I.subclass("esri.portal.Portal")],b);const E=new FinalizationRegistry(a=>{a.remove()});return c});