UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.8 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Error.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{unpackFieldNames as s,populateMissingFields as a}from"../../../../layers/support/fieldUtils.js";import{getFetchPopupTemplate as o,getRequiredFields as p}from"../../../layers/support/popupUtils.js";const i=i=>{let c=class extends i{_validateFetchPopupFeatures(e){const{layer:r}=this,{popupEnabled:s}=r;if(!s)throw new t("scenelayerview3d:fetchPopupFeatures","Popups are disabled",{layer:r});if(!o(r,e))throw new t("scenelayerview3d:fetchPopupFeatures","Layer does not define a popup template",{layer:r})}async prepareFetchPopupFeatures(e){}async fetchPopupFeaturesFromGraphics(e,t){if(this._validateFetchPopupFeatures(t),0===e.length)return[];const r="scene"===this.layer.type&&null!=this.layer.associatedLayer?this.layer.associatedLayer:this.layer;let i=[];"fieldsIndex"in this.layer&&(i=s(this.layer.fieldsIndex,await p(r,o(this.layer,t)))),await this.prepareFetchPopupFeatures(i);const c=new Set,n=[],l=[];for(const s of e)a(i,s,c)?l.push(s):n.push(s);if(0===l.length)return n;const u=new Map;for(let s=0;s<e.length;s++)u.set(e[s].getObjectId()??0,s);const h=await this.whenGraphicAttributes(l,[...c]).catch((()=>l)).then((e=>n.concat(e)));return h.sort(((e,t)=>{const r=e.getObjectId()??0,s=u.get(r)??0,a=t.getObjectId()??0;return s-(u.get(a)??0)})),h}};return c=e([r("esri.views.3d.layers.support.PopupSceneLayerView")],c),c};export{i as PopupSceneLayerView};