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.
 
 

12 lines
4.7 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 exports ../chunks/tslib.es6 ../core/asyncUtils ../core/deprecate ../core/Error ../core/has ../core/Logger ../core/promiseUtils ../core/reactiveUtils ../core/accessorSupport/decorators/property ../core/RandomLCG ../core/accessorSupport/decorators/subclass ./input/InputManager".split(" "),function(r,t,n,z,u,A,B,p,k,q,v,F,C,D){function h(d){return null!=d&&"open"in d&&"declaredClass"in d}function w(d){return null!=d&&"declaredClass"in d&&"dockOptions"in d}const x=d=>Object.freeze(Object.defineProperty({__proto__:null,
default:d},Symbol.toStringTag,{value:"Module"}));class E{constructor(d){this.layerView=d;this._resolver=k.createResolver();this.graphics=[]}get promise(){return this._resolver.promise}resolve(d){const {layerView:a,graphics:b,_resolver:e}=this;if(!a)return e.resolve(b),e.promise;let g;a.fetchPopupFeaturesFromGraphics(b,d).catch(c=>{g=c;return null}).then(c=>{c?e.resolve(c):e.reject(g)});return e.promise}}t.PopupView=d=>{d=class extends d{constructor(){super(...arguments);this._popupSetupTask=null;
this.popup={};this.popupEnabled=!0}initialize(){this.addHandles([q.watch(()=>[this.ui,this.popup],([a,b],e)=>{if(e){const [g,c]=e;g&&h(c)&&(c.view=null,w(c)&&g.remove(c,"popup"))}a&&h(b)&&(b.view=this,w(b)&&a.add(b,{key:"popup",position:"manual",internal:!0}))},q.initial),this.on("click",a=>{this.popup&&this.popupEnabled&&("mouse"!==a.pointerType||0===a.button)&&(h(this.popup)?this.popup.viewModel.handleViewClick(a):a.async(async()=>{await this.setupPopup();h(this.popup)&&!this.destroyed&&this.ready&&
this.popupEnabled&&this.popup.viewModel.handleViewClick(a)}))},D.ViewEventPriorities.WIDGET)]);q.whenOnce(()=>this.ready&&this.popupEnabled&&!this.updating).then(()=>{new Promise((a,b)=>r(["../widgets/Popup"],e=>a(x(e)),b))})}destroy(){this.destroyed||this.closePopup()}async openPopup(a){if(h(this.popup))return this.popup.open(a);try{await this.setupPopup(),this.popup?this.popup.open(a):p.getLogger(this).error(new A("view:null-popup","Popup is null and can't be opened"))}catch{}}closePopup(){this._popupSetupTask?.abort();
h(this.popup)&&this.popup.close()}async fetchPopupFeatures(a,b){await this.when();return this._popupHitsToFeatures(await this._getPopupHits(a,b),b)}async setupPopup(){this._popupSetupTask?.abort();if(this.popup&&!h(this.popup))return this._popupSetupTask=z.createTask(async a=>{const {default:b}=await new Promise((e,g)=>r(["../widgets/Popup"],c=>e(x(c)),g));k.throwIfAborted(a);this.popup&&!h(this.popup)&&(a=this.popup,delete a.open,delete a.close,this.popup=new b(a))}),this._popupSetupTask.promise}async _popupHitsToFeatures({location:a,
hits:b},e){const g=[],c=[];let l=!1;const y=k.wrapAbortWithTimeout(e,B("popup-view-fetch-timeout")??5E3);e=f=>{const m=c.at(-1);m&&m.layerView===f&&!l?f=m:(f=new E(f),c.push(f),g.push(f.promise));return f};for(const f of b)"graphic"in f?(e(f.layerView).graphics.push(f.graphic),l=!1):(g.push(f.layerView.fetchPopupFeaturesAtLocation(f.mapPoint,y)),l=!0);c.map(f=>f.resolve(y));b=k.allSettledValues(g).then(f=>f.filter(m=>!!m).flat());return{pendingFeatures:g,allGraphicsPromise:b,location:a}}async _getPopupHits(a,
b){const {hits:e,location:g}=await this.popupHitTest(a);k.throwIfAborted(b);a=[];for(const c of e)if("graphic"in c){if(this._isValidPopupGraphic(c.graphic,b)){const l=this._isValidPopupGraphicsLayerView(c.layerView)?c.layerView:void 0;a.push({graphic:c.graphic,layerView:l})}}else this._isValidPopupLocationLayerView(c.layerView)&&a.push({mapPoint:c.mapPoint,layerView:c.layerView});return{hits:a,location:g}}_isValidPopupGraphic(a,b){return a&&!!a.getEffectivePopupTemplate(b?.defaultPopupTemplateEnabled)}_isValidPopupGraphicsLayerView(a){return!a||
(!("layer"in a)||!a.suspended)&&"fetchPopupFeaturesFromGraphics"in a}_isValidPopupLocationLayerView(a){return(!("layer"in a)||!a.suspended)&&"fetchPopupFeaturesAtLocation"in a}};n.__decorate([v.property({cast(a){if(!a||h(a))return a;"object"===typeof a&&(a.open=b=>{u.deprecated(p.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"});return this.openPopup(b)},a.close=
()=>{u.deprecated(p.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"});return this.closePopup()});return a}})],d.prototype,"popup",void 0);n.__decorate([v.property()],d.prototype,"popupEnabled",void 0);return d=n.__decorate([C.subclass("esri.views.PopupView")],d)};Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});