Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

11 lines
4.1 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("../../../chunks/tslib.es6 ../../../core/Accessor ../../../core/Identifiable ../../../core/accessorSupport/decorators/property ../../../core/has ../../../core/Logger ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass".split(" "),function(h,f,u,k,w,x,y,v){var p;f=p=class extends u.NumericIdentifiableMixin(f){constructor(a){super(a);this._lodByScale={};this._scales=[];this.effectiveLODs=null;this.effectiveMaxZoom=this.effectiveMinZoom=-1;this.effectiveMaxScale=this.effectiveMinScale=
0;this.lods=null;this.maxZoom=this.minZoom=-1;this.maxScale=this.minScale=0;this.snapToZoom=!0}initialize(){let {lods:a,minScale:b,maxScale:c,minZoom:e,maxZoom:d}=this,l=-1,m=-1,q=!1,r=!1;0!==b&&0!==c&&b<c&&([b,c]=[c,b]);if(a?.length){a=a.map(g=>g.clone());a.sort((g,n)=>n.scale-g.scale);a.forEach((g,n)=>g.level=n);for(const g of a){!q&&0<b&&b>=g.scale&&(l=g.level,q=!0);!r&&0<c&&c>=g.scale&&(m=t?t.level:-1,r=!0);var t=g}-1===e&&(e=0===b?0:l);-1===d&&(d=0===c?a.length-1:m);e=Math.max(e,0);e=Math.min(e,
a.length-1);d=Math.max(d,0);d=Math.min(d,a.length-1);e>d&&([e,d]=[d,e]);b=a[e].scale;c=a[d].scale;a.splice(0,e);a.splice(d-e+1,a.length);a.forEach((g,n)=>{this._lodByScale[g.scale]=g;this._scales[n]=g.scale});this._set("effectiveLODs",a);this._set("effectiveMinZoom",e);this._set("effectiveMaxZoom",d)}this._set("effectiveMinScale",b);this._set("effectiveMaxScale",c)}constrain(a,b){if(b&&a.scale===b.scale)return a;var c=this.effectiveMinScale;const e=this.effectiveMaxScale,d=a.targetGeometry,l=b&&b.targetGeometry,
m=0!==c&&a.scale>c;if(0!==e&&a.scale<e||m)c=m?c:e,b&&l&&(b=(c-b.scale)/(a.scale-b.scale),d.x=l.x+(d.x-l.x)*b,d.y=l.y+(d.y-l.y)*b),a.scale=c;this.snapToZoom&&this.effectiveLODs&&(a.scale=this._getClosestScale(a.scale));return a}fit(a){if(!this.effectiveLODs||!this.snapToZoom)return this.constrain(a,null);const b=this.scaleToZoom(a.scale);a.scale=this.zoomToScale(.99<Math.abs(b-Math.floor(b))?Math.round(b):Math.floor(b));return a}zoomToScale(a){if(!this.effectiveLODs)return 0;a-=this.effectiveMinZoom;
a=Math.max(0,a);const b=this._scales;if(0>=a)return b[0];if(a>=b.length)return b[b.length-1];const c=Math.floor(a);return b[c]+(a-c)*(b[Math.ceil(a)]-b[c])}scaleToZoom(a){if(!this.effectiveLODs)return-1;const b=this._scales;let c,e;if(a>=b[0])return this.effectiveMinZoom;if(a<=b[b.length-1])return this.effectiveMaxZoom;for(let d=0;d<b.length-1;d++){c=b[d];e=b[d+1];if(e===a)return d+this.effectiveMinZoom+1;if(c>a&&e<a)return d+this.effectiveMinZoom+1-(a-e)/(c-e)}return-1}snapToClosestScale(a){if(!this.effectiveLODs)return a;
a=this.scaleToZoom(a);return this.zoomToScale(Math.round(a))}snapToNextScale(a,b=.5){if(!this.effectiveLODs)return a*b;a=Math.round(this.scaleToZoom(a));return this.zoomToScale(a+1)}snapToPreviousScale(a,b=2){if(!this.effectiveLODs)return a*b;a=Math.round(this.scaleToZoom(a));return this.zoomToScale(a-1)}clone(){return new p({lods:this.lods,minZoom:this.minZoom,maxZoom:this.maxZoom,minScale:this.minScale,maxScale:this.maxScale})}_getClosestScale(a){if(this._lodByScale[a])return this._lodByScale[a].scale;
a=this._scales.reduce((b,c)=>Math.abs(c-a)<=Math.abs(b-a)?c:b,this._scales[0]);return this._lodByScale[a].scale}};h.__decorate([k.property({readOnly:!0})],f.prototype,"effectiveLODs",void 0);h.__decorate([k.property({readOnly:!0})],f.prototype,"effectiveMinZoom",void 0);h.__decorate([k.property({readOnly:!0})],f.prototype,"effectiveMaxZoom",void 0);h.__decorate([k.property({readOnly:!0})],f.prototype,"effectiveMinScale",void 0);h.__decorate([k.property({readOnly:!0})],f.prototype,"effectiveMaxScale",
void 0);h.__decorate([k.property()],f.prototype,"lods",void 0);h.__decorate([k.property()],f.prototype,"minZoom",void 0);h.__decorate([k.property()],f.prototype,"maxZoom",void 0);h.__decorate([k.property()],f.prototype,"minScale",void 0);h.__decorate([k.property()],f.prototype,"maxScale",void 0);h.__decorate([k.property()],f.prototype,"snapToZoom",void 0);return f=p=h.__decorate([v.subclass("esri.views.2d.constraints.ZoomConstraint")],f)});