UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.94 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{destroyHandle as o}from"../../../../../core/handleUtils.js";import{initial as r}from"../../../../../core/reactiveUtils.js";import{property as i}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as n}from"../../../../../core/support/UpdatingHandles.js";import{projectWithZConversion as a}from"../../../../../geometry/projectionUtils.js";import{EditGeometryOperations as d}from"../../../../interactive/editGeometry/EditGeometryOperations.js";let p=class extends t{get operations(){return this._operations}get updating(){return this._updatingHandles.updating}constructor(e){super(e),this._updatingHandles=new n}initialize(){this.addHandles([o(this._updatingHandles),this._updatingHandles.add((()=>this.element.georeference?.coords),(e=>this._elementCoordinatesChanged(e)),r)])}_elementCoordinatesChanged(e){this._updatedElementCoordinates!==e&&this._updatingHandles.addPromise(this._whenProjected(e,this.view.spatialReference,(e=>{if(!e)return void this._replaceOperations(null);const{_operations:t}=this;t?.trySetGeometry(e)?this.onModifiedExternally():this._replaceOperations(d.fromGeometry(e,this.view.state.viewingMode))})))}_operationsGeometryChanged(){const{element:{georeference:e},_operations:t}=this;if(!t||!e)return;const o=t.data.geometry;if(!e.coords)return void this._updateElementCoordinates(o);const r=e.coords.spatialReference;this._updatingHandles.addPromise(this._whenProjected(o,r,(e=>this._updateElementCoordinates(e))))}_updateElementCoordinates(e){const{georeference:t}=this.element;t&&(t.coords=e,this._updatedElementCoordinates=t.coords)}async _whenProjected(e,t,o){if(!e)return void o(e);const{_operations:r,element:{georeference:i}}=this,s=await a(e,t);r===this._operations&&i===this.element.georeference&&o(s)}_replaceOperations(e){this._operations&&(this.removeHandles(this._operations),this._operations.destroy()),this._operations=e,e&&this.addHandles(e.data.on("change",(()=>this._operationsGeometryChanged())),e),this.onModifiedExternally()}};e([i({constructOnly:!0})],p.prototype,"view",void 0),e([i({constructOnly:!0})],p.prototype,"layer",void 0),e([i({constructOnly:!0})],p.prototype,"element",void 0),e([i({constructOnly:!0})],p.prototype,"onModifiedExternally",void 0),e([i()],p.prototype,"_operations",void 0),e([i()],p.prototype,"operations",null),e([i()],p.prototype,"updating",null),p=e([s("esri.views.3d.interactive.editingTools.media.MediaElementControllerShape")],p);export{p as MediaElementControllerShape};