UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 1.56 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{findLayerView as o}from"./layerUtils.js";import{defaultHighlightName as s}from"../../support/HighlightDefaults.js";import{highlightsSupported as h}from"../../support/layerViewUtils.js";let a=class extends t{constructor(e){super(e),this._layerViewCache=new Map,this.highlightName=s,this.view=null}add(e,t){const r=!e||Array.isArray(e)?e:[e];if(!r?.length)return;const i=t??this.highlightName;r.forEach(e=>this._highlight(e,i))}getKeyForFeature(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}remove(e){const t=!e||Array.isArray(e)?e:[e];t?.length&&t.forEach(e=>e&&this._removeHighlight(this.getKeyForFeature(e)))}removeByKey(e){e?.forEach(e=>e&&this._removeHighlight(e))}removeAll(){this.removeAllHandles()}update(e,t){this.remove(e),this.add(e,t)}_highlight(e,t){const r=e.layer??e.sourceLayer;if(!r)return;const i=this._layerViewCache.get(r);if(i)return void this.addHandles(i.highlight(e,{name:t}),this.getKeyForFeature(e));const s=o(this.view,r);h(s)&&(this._layerViewCache.set(r,s),this.addHandles(s.highlight(e,{name:t}),this.getKeyForFeature(e)))}_removeHighlight(e){this.removeHandles(e)}};e([r()],a.prototype,"_layerViewCache",void 0),e([r()],a.prototype,"highlightName",void 0),e([r()],a.prototype,"view",void 0),a=e([i("esri.views.draw.support.HighlightHelper")],a);const l=a;export{l as default};