MapViewConstraints.js 3.7 KB

12345
  1. /*
  2. All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. See https://js.arcgis.com/4.24/esri/copyright.txt for details.
  4. */
  5. import{_ as o}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../core/Accessor.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import s from"../../layers/support/LOD.js";import{GeometryConstraint as i}from"./constraints/GeometryConstraint.js";import n from"./constraints/RotationConstraint.js";import a from"./constraints/ZoomConstraint.js";import m from"../../geometry/Extent.js";import l from"../../geometry/Polygon.js";const p={base:null,key:"type",typeMap:{extent:m,polygon:l}};let c=class extends t{constructor(o){super(o),this.lods=null,this.minScale=0,this.maxScale=0,this.minZoom=-1,this.maxZoom=-1,this.rotationEnabled=!0,this.snapToZoom=!0}destroy(){this.view=null,this._set("_zoom",null),this._set("_rotation",null),this._set("_geometry",null)}set geometry(o){o?this._set("geometry",o):this._set("geometry",null)}get version(){return this.commitProperty("_zoom"),this.commitProperty("_rotation"),this.commitProperty("_geometry"),(this._get("version")??0)+1}get _defaultLODs(){const o=this.view?.defaultsFromMap?.tileInfo,t=this.view?.spatialReference;return o&&t&&o.spatialReference.equals(t)?o.lods:null}get _geometry(){return new i({geometry:this.geometry,spatialReference:this.view?.spatialReference})}get _rotation(){return new n({rotationEnabled:this.rotationEnabled})}get _zoom(){const o=this._get("_zoom"),t=this.lods||this._defaultLODs,e=this.minZoom,r=this.maxZoom,s=this.minScale,i=this.maxScale,n=this.snapToZoom;return o&&o.lods===t&&o.minZoom===e&&o.maxZoom===r&&o.minScale===s&&o.maxScale===i&&o.snapToZoom===n?o:new a({lods:t,minZoom:e,maxZoom:r,minScale:s,maxScale:i,snapToZoom:n})}canZoomInTo(o){const t=this.effectiveMaxScale;return 0===t||o>=t}canZoomOutTo(o){const t=this.effectiveMinScale;return 0===t||o<=t}constrain(o,t){return this._zoom.constrain(o,t),this._rotation.constrain(o,t),this._geometry.constrain(o,t),o}constrainByGeometry(o){return this._geometry.constrain(o)}fit(o){return this._zoom.fit(o)}zoomToScale(o){return this._zoom.zoomToScale(o)}scaleToZoom(o){return this._zoom.scaleToZoom(o)}snapScale(o){return this._zoom.snapToClosestScale(o)}snapToNextScale(o){return this._zoom.snapToNextScale(o)}snapToPreviousScale(o){return this._zoom.snapToPreviousScale(o)}};o([e({readOnly:!0,aliasOf:"_zoom.effectiveLODs"})],c.prototype,"effectiveLODs",void 0),o([e({readOnly:!0,aliasOf:"_zoom.effectiveMinScale"})],c.prototype,"effectiveMinScale",void 0),o([e({readOnly:!0,aliasOf:"_zoom.effectiveMaxScale"})],c.prototype,"effectiveMaxScale",void 0),o([e({readOnly:!0,aliasOf:"_zoom.effectiveMinZoom"})],c.prototype,"effectiveMinZoom",void 0),o([e({readOnly:!0,aliasOf:"_zoom.effectiveMaxZoom"})],c.prototype,"effectiveMaxZoom",void 0),o([e({types:p,value:null})],c.prototype,"geometry",null),o([e({type:[s]})],c.prototype,"lods",void 0),o([e()],c.prototype,"minScale",void 0),o([e()],c.prototype,"maxScale",void 0),o([e()],c.prototype,"minZoom",void 0),o([e()],c.prototype,"maxZoom",void 0),o([e()],c.prototype,"rotationEnabled",void 0),o([e()],c.prototype,"snapToZoom",void 0),o([e()],c.prototype,"view",void 0),o([e({readOnly:!0})],c.prototype,"version",null),o([e()],c.prototype,"_defaultLODs",null),o([e({type:i})],c.prototype,"_geometry",null),o([e({type:n})],c.prototype,"_rotation",null),o([e({readOnly:!0,type:a})],c.prototype,"_zoom",null),c=o([r("esri.views.2d.MapViewConstraints")],c);const y=c;export{y as default};