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("../../chunks/tslib.es6 ../../core/Accessor ../../core/asyncUtils ../../core/Collection ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../../geometry/Extent ../../geometry/SpatialReference ../../geometry/support/contains ../../geometry/support/webMercatorUtils ../../views/3d/layers/Lyr3DWasm".split(" "),function(p,l,y,t,q,r,F,G,H,z,A,B,C,u,D){function v(b,c){return b&&
"copyright"in b&&(!c||"function"===typeof b.originOf&&"user"===b.originOf("copyright"))}function E(b,c){return b.length!==c.length||b.some((d,a)=>d.text!==c[a].text)}function n(b,c,d){d&&c&&(b.find(a=>a.layerView===c&&a.text===d)||b.push({text:d,layerView:c}))}const k=[];l=class extends l{constructor(b){super(b);this._clear=()=>{this._fetchedAttributionData.clear();this._pendingAttributions.clear();this.removeHandles("suspension");this.notifyChange("state")};this._pendingAttributions=new Set;this._fetchedAttributionData=
new Map;this.items=new t;this.view=null;this._allLayerViewsChange=c=>{this.removeHandles("suspension");this.removeHandles("visible-geometry-changed");const d=this.view?.allLayerViews;d&&(this.addHandles(d.map(a=>q.watch(()=>[a.suspended,a.layer?.attributionVisible],()=>this._updateAttributionItems())).toArray(),"suspension"),d.forEach(a=>{"esri.views.3d.layers.Tiles3DLayerView3D"===a.declaredClass&&this.addHandles(a.on("visible-geometry-changed",()=>this._updateAttributionItems()),"visible-geometry-changed")}));
c?.removed&&c.removed.forEach(a=>{this._pendingAttributions.delete(a);this._fetchedAttributionData.delete(a)});this._updateAttributionItems()};this.addHandles([q.on(()=>this.view?.allLayerViews,"change",c=>this._allLayerViewsChange(c),{onListenerAdd:()=>this._allLayerViewsChange(),onListenerRemove:this._clear}),q.when(()=>!0===this.view?.stationary,()=>this._updateAttributionItems())])}destroy(){this.view=null;this._fetchedAttributionData.clear();this._pendingAttributions.clear();this.items.removeAll()}get state(){return this.view?.ready?
0<this._pendingAttributions.size?"loading":"ready":"disabled"}_updateAttributionItems(){const b=this.view;var c=b?.allLayerViews;k.length=0;if(b&&c){c.forEach(a=>{if(!a.suspended&&a.layer?.attributionVisible){var e=a.layer;if(v(e,"user"))n(k,a,e.copyright);else if(e.hasAttributionData)if(this._fetchedAttributionData.has(a)){var h=this._fetchedAttributionData.get(a);h?n(k,a,this._getDynamicAttribution(h,b,e)):v(e)&&n(k,a,e.copyright)}else this._fetchAttributionData(a);else(h="portalItem"in e?e.portalItem?.accessInformation:
void 0)?n(k,a,h):n(k,a,e.copyright)}});c=c.find(a=>"integrated-mesh-3dtiles"===a.layer?.type);if(this.view&&c){var d=D.getLyr3DWasm(this.view);if(d){d=d.getAttributionText();for(let a=0;a<d.length;++a)n(k,c,d[a])}}E(this.items,k)&&(this.items.removeAll(),this.items.addMany(k));k.length=0;this.notifyChange("state")}else this._clear()}async _fetchAttributionData(b){if(!this._pendingAttributions.has(b)){this._pendingAttributions.add(b);var c=await y.result(b.layer.fetchAttributionData());this._pendingAttributions.has(b)&&
(c=c.ok?this._createContributionIndex(c.value,"bing-maps"===b.layer.type):null,this._pendingAttributions.delete(b),this._fetchedAttributionData.set(b,c));this._updateAttributionItems()}}_createContributionIndex(b,c){b=b.contributors;const d={};if(!b)return d;for(let m=0;m<b.length;m++){const f=b[m];var a=f.coverageAreas;if(!a)return;for(const g of a){var e=g.bbox,h=g.zoomMin-(c&&g.zoomMin?1:0);a=g.zoomMax-(c&&g.zoomMax?1:0);e=new A({xmin:e[1],ymin:e[0],xmax:e[3],ymax:e[2],spatialReference:B.WGS84});
for(e={extent:u.geographicToWebMercator(e),attribution:f.attribution||"",score:null!=g.score?g.score:100,id:m};h<=a;h++){let w,x;(w=d)[x=h]??(w[x]=[]);d[h].push(e)}}}d.maxKey=Math.max.apply(null,Object.keys(d));return d}_getDynamicAttribution(b,c,d){const {extent:a,scale:e}=c;d=d.tileInfo?.scaleToZoom(e)??0;d=Math.min(b.maxKey??0,Math.round(d));if(!a||null==d||-1>=d)return"";b=b[d];const h=u.project(a.center.clone().normalize(),c.spatialReference),m=new Set;return b?b.filter(f=>{const g=f.id;(f=!m.has(g)&&
h&&f.extent&&C.extentContainsPoint(f.extent,h))&&m.add(g);return f}).sort((f,g)=>g.score-f.score||f.objectId-g.objectId).map(f=>f.attribution).join(", "):""}};p.__decorate([r.property({readOnly:!0,type:t})],l.prototype,"items",void 0);p.__decorate([r.property({readOnly:!0})],l.prototype,"state",null);p.__decorate([r.property()],l.prototype,"view",void 0);return l=p.__decorate([z.subclass("esri.widgets.Attribution.AttributionViewModel")],l)});