@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.74 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{__decorate as e}from"tslib";import i from"../../../Graphic.js";import{isSome as s}from"../../../core/arrayUtils.js";import t from"../../../core/Collection.js";import{makeHandle as r}from"../../../core/handleUtils.js";import{watch as a,initial as o,on as h}from"../../../core/reactiveUtils.js";import{subclass as n}from"../../../core/accessorSupport/decorators.js";import{LayerView2D as l}from"./LayerView2D.js";import p from"./graphics/GraphicContainer.js";import c from"./graphics/GraphicsView2D.js";import g from"../../layers/LayerView.js";import{getHighlightName as d}from"../../support/highlightOptionsUtils.js";const u="sublayers",f="layerView";let w=class extends(l(g)){*graphicsViews(){null==this._graphicsViewsFeatureCollectionMap?null==this._graphicsViews?yield*[]:yield*this._graphicsViews:yield*this._graphicsViewsFeatureCollectionMap.keys()}async hitTest(e,i){return Array.from(this.graphicsViews(),i=>{const s=i.hitTest(e);if(null!=this._graphicsViewsFeatureCollectionMap){const e=this._graphicsViewsFeatureCollectionMap.get(i);for(const i of s)!i.popupTemplate&&e.popupTemplate&&(i.popupTemplate=e.popupTemplate),i.sourceLayer=i.layer=this.layer}return s}).flat().map(i=>({type:"graphic",graphic:i,layer:this.layer,mapPoint:e}))}highlight(e,a){let o;"number"==typeof e?o=[e]:e instanceof i?o=[e.uid]:Array.isArray(e)&&e.length>0?o="number"==typeof e[0]?e:e.map(e=>e&&e.uid):t.isCollection(e)&&(o=e.map(e=>e&&e.uid).toArray());const h=o?.filter(s);if(!h?.length)return r();const n=d(a);return this._addHighlights(h,n),r(()=>this._removeHighlights(h,n))}update(e){for(const i of this.graphicsViews())i.processUpdate(e)}attach(){const e=this.view,i=()=>this.requestUpdate(),s=this.layer.featureCollections;if(null!=s&&s.length){this._graphicsViewsFeatureCollectionMap=new Map;for(const t of s){const s=new p(this.view.featuresTilingScheme),r=new c({view:e,graphics:t.source,renderer:t.renderer,requestUpdateCallback:i,container:s});this._graphicsViewsFeatureCollectionMap.set(r,t),this.container.addChild(r.container),this.addHandles([a(()=>t.visible,e=>r.container.visible=e,o),a(()=>r.updating,()=>this.notifyChange("updating"),o)],f)}this._processHighlight()}else null!=this.layer.sublayers&&this.addHandles(h(()=>this.layer.sublayers,"change",()=>this._createGraphicsViews(),{onListenerAdd:()=>this._createGraphicsViews(),onListenerRemove:()=>this._destroyGraphicsViews()}),u)}detach(){this._destroyGraphicsViews(),this.removeHandles(u)}moveEnd(){}viewChange(){for(const e of this.graphicsViews())e.viewChange()}isUpdating(){for(const e of this.graphicsViews())if(e.updating)return!0;return!1}_destroyGraphicsViews(){this.container.removeAllChildren(),this.removeHandles(f);for(const e of this.graphicsViews())e.destroy();this._graphicsViews=null,this._graphicsViewsFeatureCollectionMap=null}_createGraphicsViews(){if(this._destroyGraphicsViews(),null==this.layer.sublayers)return;const e=[],i=this.view,s=()=>this.requestUpdate();for(const t of this.layer.sublayers){const r=new p(this.view.featuresTilingScheme);r.fadeTransitionEnabled=!0;const h=new c({view:i,graphics:t.graphics,requestUpdateCallback:s,container:r});this.addHandles([t.on("graphic-update",h.graphicUpdateHandler),a(()=>t.visible,e=>h.container.visible=e,o),a(()=>h.updating,()=>this.notifyChange("updating"),o)],f),this.container.addChild(h.container),e.push(h)}this._graphicsViews=e,this._processHighlight()}_processHighlight(){const e=this._getHighlights();for(const i of this._graphicsViews||[])i.setHighlight(e);this._graphicsViewsFeatureCollectionMap?.forEach((i,s)=>{s.setHighlight(e)})}};w=e([n("esri.views.2d.layers.MapNotesLayerView2D")],w);const m=w;export{m as default};