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.
37 lines
17 KiB
37 lines
17 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 ../../geometry ../../Graphic ../../symbols ../../core/arrayUtils ../../core/Error ../../core/Logger ../../core/promiseUtils ../../core/ReactiveSet ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/accessorSupport/decorators/subclass ../../geometry/projection ../../geometry/support/geometryUtils ../../geometry/support/webMercatorUtils ../../layers/Layer ../../layers/LayerConstants ../../symbols/support/symbolUtils ../../time/timeZoneUtils ../../views/support/layerViewUtils ../Feature/FeatureViewModel ../Popup/actions ../Popup/actionUtils ../support/AnchorElementViewModel ../support/GoTo ../../symbols/SimpleFillSymbol ../../geometry/Point".split(" "), |
|
function(H,g,f,I,V,J,B,w,z,K,m,h,W,L,C,D,M,E,N,F,O,G,P,t,q,Q,R,S,T){let A=null;f=class extends R.GoToMixin(Q){constructor(a){super(a);this._pendingPromises=new K;this._selectedClusterFeature=this._highlightActiveFeaturePromise=this._highlightSelectedFeaturePromise=this._fetchFeaturesController=null;this.actions=new t.ActionsCollection;this.activeFeature=null;this.browseClusterEnabled=this.autoCloseEnabled=!1;this.content=null;this.defaultPopupTemplateEnabled=!1;this.featurePage=null;this.featuresPerPage= |
|
20;this.featureMenuOpen=!1;this.featureViewModelAbilities=null;this.featureViewModels=[];this.includeDefaultActions=this.highlightEnabled=!0;this.selectedClusterBoundaryFeature=new I({symbol:new S({outline:{width:1.5,color:"cyan"},style:"none"})});this.title=null;this.updateLocationEnabled=!1;this.view=null;this.visible=!1;this.zoomFactor=4;this.zoomToLocation=null;this._debouncedLocationUpdate=z.debounce(async b=>{const {spatialReference:c}=this,d=this.selectedFeature?.geometry?.type;b=this.location?? |
|
b;if(d&&"mesh"!==d&&c&&b&&this.selectedFeature)if("point"===d)this.location=D.getPointFromGeometry(this.selectedFeature.geometry)??b;else try{const e=this.selectedFeature;let k=e.geometry;const l=this._getHighlightLayer(e),u=e.getObjectId();if(l&&this.view){if(u){const n=this.view?.allLayerViews.find(x=>x.layer.uid===l.uid);if(!(n&&"queryFeatures"in n))return;const p=n.createQuery();p.outSpatialReference=c;p.objectIds=[u];p.returnGeometry=!0;const {features:r}=await n.queryFeatures(p);k=r[0]?.geometry}if(k&& |
|
"mesh"!==k.type&&(k=C.project(k,c),A||=await new Promise((n,p)=>H(["../../geometry/geometryEngineAsync"],n,p)),!await A.intersects(k,b))){const n=(await A.nearestCoordinate(k,b)).coordinate??b;this.selectedFeature===e&&(this.location=n)}}}catch(e){z.isAbortError(e)||w.getLogger(this).error(e)}})}initialize(){this.addHandles([this.on("view-change",()=>this._autoClose()),m.watch(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),m.watch(()=> |
|
[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),m.watch(()=>this.view?.animation?.state,a=>this._animationStateChange(a)),m.watch(()=>this.location,a=>this._locationChange(a)),m.watch(()=>this.selectedFeature,a=>this._selectedFeatureChange(a)),m.watch(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),m.watch(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage, |
|
this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),m.watch(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on("trigger-action",a=>q.triggerAction({event:a,viewModel:this,view:this.view})),m.when(()=>!this.waitingForResult,()=>this._waitingForResultChange(),m.sync),m.watch(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),m.watch(()=>this.view?.scale,()=>this._viewScaleChange()),m.when(()=>!this.visible,()=>this.browseClusterEnabled= |
|
!1),m.watch(()=>this.browseClusterEnabled,a=>a?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelFetchingFeatures();this._pendingPromises.clear();this.browseClusterEnabled=!1;this.timeZone=this.spatialReference=this.map=this.view=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){const a=this._get("allActions")||new t.ActionsCollection;a.removeAll();const {actions:b,defaultActions:c,defaultPopupTemplateEnabled:d,includeDefaultActions:e, |
|
selectedFeature:k}=this,l=e?c.concat(b):b,u=k&&("function"===typeof k.getEffectivePopupTemplate&&k.getEffectivePopupTemplate(d)||k.popupTemplate),n=u?.actions;(u?.overwriteActions?n:n?.concat(l)??l)?.filter(Boolean).forEach(p=>a.add(p));return a}get defaultActions(){const a=this._get("defaultActions")||new t.ActionsCollection;a.removeAll();a.addMany(q.isClusterFeature(this.selectedFeature)?[t.zoomToClusteredFeatures.clone(),t.browseClusteredFeatures.clone()]:[t.zoomToFeature.clone()]);return a}get featureCount(){return this.features.length}set features(a){a= |
|
a||[];this._set("features",a);const {pendingPromisesCount:b,promiseCount:c,selectedFeatureIndex:d}=this,e=c&&a.length;e&&b&&-1===d?this.selectedFeatureIndex=0:e&&-1!==d||(this.selectedFeatureIndex=a.length?0:-1)}set location(a){let b=a;const c=this.spatialReference?.isWebMercator;a?.spatialReference?.isWGS84&&c&&(b=M.geographicToWebMercator(a));this._set("location",b)}get map(){return this.view?.map??null}set map(a){this._override("map",a)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get("promises")|| |
|
[]}set promises(a){this._pendingPromises.clear();this.features=[];Array.isArray(a)&&a.length?(this._set("promises",a),a=a.slice(0),a.forEach(b=>this._pendingPromises.add(b)),a.reduce((b,c)=>b.finally(()=>c.then(d=>{this._pendingPromises.has(c)&&this._updateFeatures(d)}).finally(()=>this._pendingPromises.delete(c)).catch(()=>{})),Promise.resolve())):this._set("promises",[])}get selectedFeature(){const {features:a,selectedFeatureIndex:b}=this;return-1===b?null:a[b]||null}get selectedFeatureIndex(){const a= |
|
this._get("selectedFeatureIndex");return"number"===typeof a?a:-1}set selectedFeatureIndex(a){const {featureCount:b}=this;a=isNaN(a)||-1>a||!b?-1:(a+b)%b;this.activeFeature=null;this._set("selectedFeatureIndex",a)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(a){this._override("spatialReference",a)}get state(){const {view:a,map:b}=this;return a?a.ready?"ready":"disabled": |
|
b?"ready":"disabled"}get timeZone(){return this.view?.timeZone??O.system}set timeZone(a){this._overrideIfSome("timeZone",a)}get waitingForContents(){return this.featureViewModels.some(a=>a.waitingForContent)}get waitingForResult(){return!(!(this._fetchFeaturesController||0<this.pendingPromisesCount)||0!==this.featureCount)}centerAtLocation(){const {view:a}=this,b=q.getSelectedTarget(this);return b&&a?this.callGoTo({target:{target:b,scale:a.scale}}):Promise.reject(new B("center-at-location:invalid-target-or-view", |
|
"Cannot center at a location without a target and view.",{target:b,view:a}))}zoomTo(a){return this.callGoTo(a)}clear(){this.set({promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(a,b){const {view:c}=this;if(!c||!a)throw new B("fetch-features:invalid-screenpoint-or-view","Cannot fetch features without a screenPoint and view.",{screenPoint:a,view:c});return c.fetchPopupFeatures(a,{pointerType:b?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled, |
|
signal:b?.signal})}open(a){a={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...a,visible:!0};var {fetchFeatures:b}=a;delete a.fetchFeatures;b&&this._setFetchFeaturesPromises(a.location);b=["actionsMenuOpen","collapsed"];for(const c of b)delete a[c];this.set(a)}triggerAction(a){(a=this.allActions.at(a))&&!a.disabled&&this.emit("trigger-action",{action:a})}next(){this.selectedFeatureIndex++;return this}previous(){this.selectedFeatureIndex--;return this}disableClusterBrowsing(){q.removeClusteredFeaturesForBrowsing(this); |
|
this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){const {view:a,selectedFeature:b}=this;"2d"!==a?.type?w.getLogger(this).warn("enableClusterBrowsing:invalid-view: View must be 2d MapView.",b):q.isClusterFeature(b)?(await q.displayClusterExtent(this),await q.browseAggregateFeatures(this)):w.getLogger(this).warn("enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.",b)}handleViewClick(a){this._fetchFeaturesAndOpen(a)}_animationStateChange(a){this.zoomToLocation|| |
|
(t.zoomToFeature.disabled="waiting-for-target"===a)}_clearBrowsedClusterGraphics(){const a=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(J.isSome);this.view?.graphics?.removeMany(a);this._selectedClusterFeature=null;this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){q.isClusterFeature(this.selectedFeature)?(this.visible=this.browseClusterEnabled=!1,this.clear()):this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(a){const {selectedFeature:b, |
|
updateLocationEnabled:c,view:d}=this;d&&c&&a&&(!b||b.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=1<this.featureCount?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=1<this.featureCount?1:null}_setGraphicOnFeatureViewModels(){const {features:a,featureCount:b,featurePage:c,featuresPerPage:d,featureViewModels:e}=this;if(null!==c){var k=((c-1)*d+b)%b;e.slice(k,k+d).forEach((l,u)=>{l&&(l.graphic??(l.graphic= |
|
a[k+u]))})}}async _selectedFeatureChange(a){const {location:b,updateLocationEnabled:c,view:d}=this;if(a&&d)if(this.browseClusterEnabled)this._selectedClusterFeature&&(d.graphics.remove(this._selectedClusterFeature),this._selectedClusterFeature=null),q.isClusterFeature(a)||(a.symbol=await F.getDisplayedSymbol(a),this._selectedClusterFeature=a,d.graphics.add(this._selectedClusterFeature));else{var e=a.sourceLayer?.type;if("map-image"===e||"imagery"===e||"imagery-tile"===e)a.symbol=await F.getDisplayedSymbol(a); |
|
!c&&b||!a.geometry?c&&!a.geometry&&(await this.centerAtLocation(),a=d.center?.clone())&&(this.location=a):this.location=D.getPointFromGeometry(a.geometry)}}_waitingForResultChange(){!this.featureCount&&this.promises&&(this.visible=!1)}async _setFetchFeaturesPromises(a){({pendingFeatures:a}=await this._fetchFeaturesWithController({mapPoint:a}));this.promises=a}_destroyFeatureVMs(){this.featureViewModels.forEach(a=>a&&!a.destroyed&&a.destroy());this._set("featureViewModels",[])}_updateFeatureVMs(){const {selectedFeature:a, |
|
features:b,featureViewModels:c,view:d,spatialReference:e,map:k,timeZone:l,location:u}=this;q.isClusterFeature(a)||(this.browseClusterEnabled=!1);this._destroyFeatureVMs();if(b?.length){var n=c.slice(0),p=[];b.forEach((r,x)=>{if(r){var y=null;n.some((v,U)=>{v&&v.graphic===r&&(y=v,n.splice(U,1));return!!y});if(y)p[x]=y;else{const v=new P({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:e,graphic:r===a?r:null,location:u,map:k,view:d, |
|
timeZone:l});p[x]=v}}});n.forEach(r=>r&&!r.destroyed&&r.destroy());this._set("featureViewModels",p)}}async _getScreenPoint(a,b){const {spatialReference:c,view:d}=this;if(!d)return null;await d?.when();const e=a?.spatialReference;if(!e||!c)return null;await C.initializeProjection(e,c,null,b);return d.toScreen(a)}_cancelFetchingFeatures(){const a=this._fetchFeaturesController;a&&a.abort();this._fetchFeaturesController=null}async _projectScreenPointAndFetchFeatures({mapPoint:a,screenPoint:b,event:c, |
|
signal:d}){return this.fetchFeatures(b??await this._getScreenPoint(a??this.location,{signal:d}),{signal:d,event:c})}_fetchFeaturesWithController({mapPoint:a,screenPoint:b,event:c}){this._cancelFetchingFeatures();const d=new AbortController,{signal:e}=d;this._fetchFeaturesController=d;a=this._projectScreenPointAndFetchFeatures({mapPoint:a,screenPoint:b,signal:e,event:c});a.catch(()=>{}).then(()=>{this._fetchFeaturesController=null});return a}async _fetchFeaturesAndOpen(a){const {mapPoint:b,screenPoint:c}= |
|
a,{view:d}=this;this.removeHandles("location-scale-handle");this.addHandles([m.watch(()=>this.view?.scale,()=>this._debouncedLocationUpdate(b).catch(e=>{z.isAbortError(e)||w.getLogger(this).error(e)})),m.when(()=>!this.visible,()=>{this.removeHandles("location-scale-handle")},{once:!0})],"location-scale-handle");({pendingFeatures:a}=await this._fetchFeaturesWithController({mapPoint:b,screenPoint:c,event:a}));d?.popup&&"open"in d.popup&&d.popup.open({location:b??void 0,promises:a})}_autoClose(){this.autoCloseEnabled&& |
|
(this.visible=!1)}async _getLayerView(a,b){await a.when();return a.whenLayerView(b)}_getHighlightLayer(a){const {layer:b,sourceLayer:c}=a;return c&&"layer"in c&&c.layer?c.layer:"map-notes"===c?.type||"subtype-group"===c?.type?c:b}_getHighlightTarget(a,b,c){var d=b.type;if("building-scene"===d||"2d"===c&&("map-image"===d||"tile"===d||"imagery"===d||"imagery-tile"===d))return a;c=a.getObjectId();if(null!=c)return c;b="imagery"===b.type?void 0:"objectIdField"in b?b.objectIdField||N.fallbackObjectIDAttribute: |
|
null;return(c=a.attributes)&&b&&c[b]||a}_mapIncludesLayer(a){return!!this.map?.allLayers?.includes(a)}async _highlightActiveFeature(){this.removeHandles("highlight-active-feature");const {highlightEnabled:a,view:b,activeFeature:c,visible:d}=this;if(c&&b&&a&&d){var e=this._getHighlightLayer(c);if(e&&e instanceof E&&this._mapIncludesLayer(e)){var k=this._getLayerView(b,e);this._highlightActiveFeaturePromise=k;var l=await k;l&&G.highlightsSupported(l)&&this._highlightActiveFeaturePromise===k&&this.activeFeature&& |
|
this.highlightEnabled&&(e=l.highlight(this._getHighlightTarget(c,e,b.type)),this.addHandles(e,"highlight-active-feature"))}}}async _highlightSelectedFeature(){this.removeHandles("highlight-selected-feature");const {selectedFeature:a,highlightEnabled:b,view:c,visible:d}=this;if(a&&c&&b&&d){var e=this._getHighlightLayer(a);if(e&&e instanceof E&&this._mapIncludesLayer(e)){var k=this._getLayerView(c,e);this._highlightSelectedFeaturePromise=k;var l=await k;l&&G.highlightsSupported(l)&&this._highlightSelectedFeaturePromise=== |
|
k&&this.selectedFeature&&this.highlightEnabled&&this.visible&&(e=l.highlight(this._getHighlightTarget(a,e,c.type)),this.addHandles(e,"highlight-selected-feature"))}}}_updateFeatures(a){const {features:b}=this;a=a.filter(c=>!b.includes(c));a?.length&&(this.features=b.concat(a))}};g.__decorate([h.property()],f.prototype,"_fetchFeaturesController",void 0);g.__decorate([h.property({type:t.ActionsCollection})],f.prototype,"actions",void 0);g.__decorate([h.property({readOnly:!0})],f.prototype,"active", |
|
null);g.__decorate([h.property()],f.prototype,"activeFeature",void 0);g.__decorate([h.property({readOnly:!0})],f.prototype,"allActions",null);g.__decorate([h.property()],f.prototype,"autoCloseEnabled",void 0);g.__decorate([h.property()],f.prototype,"browseClusterEnabled",void 0);g.__decorate([h.property()],f.prototype,"content",void 0);g.__decorate([h.property({type:t.ActionsCollection,readOnly:!0})],f.prototype,"defaultActions",null);g.__decorate([h.property({type:Boolean})],f.prototype,"defaultPopupTemplateEnabled", |
|
void 0);g.__decorate([h.property({readOnly:!0})],f.prototype,"featureCount",null);g.__decorate([h.property()],f.prototype,"featurePage",void 0);g.__decorate([h.property({value:[]})],f.prototype,"features",null);g.__decorate([h.property()],f.prototype,"featuresPerPage",void 0);g.__decorate([h.property()],f.prototype,"featureMenuOpen",void 0);g.__decorate([h.property()],f.prototype,"featureViewModelAbilities",void 0);g.__decorate([h.property({readOnly:!0})],f.prototype,"featureViewModels",void 0);g.__decorate([h.property()], |
|
f.prototype,"highlightEnabled",void 0);g.__decorate([h.property()],f.prototype,"includeDefaultActions",void 0);g.__decorate([h.property({type:T})],f.prototype,"location",null);g.__decorate([h.property()],f.prototype,"map",null);g.__decorate([h.property({readOnly:!0})],f.prototype,"pendingPromisesCount",null);g.__decorate([h.property({readOnly:!0})],f.prototype,"promiseCount",null);g.__decorate([h.property()],f.prototype,"promises",null);g.__decorate([h.property({readOnly:!0})],f.prototype,"selectedClusterBoundaryFeature", |
|
void 0);g.__decorate([h.property({value:null,readOnly:!0})],f.prototype,"selectedFeature",null);g.__decorate([h.property({value:-1})],f.prototype,"selectedFeatureIndex",null);g.__decorate([h.property({readOnly:!0})],f.prototype,"selectedFeatureViewModel",null);g.__decorate([h.property({readOnly:!0})],f.prototype,"state",null);g.__decorate([h.property()],f.prototype,"timeZone",null);g.__decorate([h.property()],f.prototype,"title",void 0);g.__decorate([h.property()],f.prototype,"updateLocationEnabled", |
|
void 0);g.__decorate([h.property()],f.prototype,"view",void 0);g.__decorate([h.property()],f.prototype,"visible",void 0);g.__decorate([h.property({readOnly:!0})],f.prototype,"waitingForContents",null);g.__decorate([h.property({readOnly:!0})],f.prototype,"waitingForResult",null);g.__decorate([h.property()],f.prototype,"zoomFactor",void 0);g.__decorate([h.property()],f.prototype,"zoomToLocation",void 0);g.__decorate([h.property()],f.prototype,"centerAtLocation",null);return f=g.__decorate([L.subclass("esri.widgets.Features.FeaturesViewModel")], |
|
f)}); |