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.
9 lines
3.2 KiB
9 lines
3.2 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/promiseUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../support/GeolocationPositioning".split(" "),function(b,f,d,a,q,r,k,l){a=class extends l{constructor(c){super(c);this._trackStartingTimeoutId=this._watchId=void 0;this._trackController=this._settingPosition=null;this.error=void 0;this.positionFilterFunction=null}destroy(){this._stopTracking()}get state(){return this._geolocationUsable? |
|
this.view&&!this.view.ready?"disabled":this._settingPosition||void 0!==this._trackStartingTimeoutId?"waiting":this.tracking?"tracking":null!=this.error?"error":"ready":"feature-unsupported"}get tracking(){return void 0!==this._watchId}start(){"disabled"!==this.state&&"feature-unsupported"!==this.state&&this._startTracking()}stop(){"disabled"!==this.state&&"feature-unsupported"!==this.state&&this._stopTracking()}_stopWatchingPosition(){void 0!==this._watchId&&(navigator.geolocation.clearWatch(this._watchId), |
|
this._watchId=void 0)}_stopTracking(){this._abortTrack();this._clearWaitingTimer();this._stopWatchingPosition();this._clearGraphic()}_startTracking(){this._stopTracking();const c=f.debounce(async e=>{this._abortTrack();const g=new AbortController;this._trackController=g;const {timestamp:m,coords:n}=e,p={timestamp:m,coords:{...n}};this.error=void 0;try{if("function"!==typeof this.positionFilterFunction||this.positionFilterFunction.call(null,{position:p}))await this.updatePosition(e,g),this._trackController=== |
|
g&&(this._clearWaitingTimer(),this._addGraphic(),this.emit("track",{position:e}),this._trackController=null)}catch(h){if(!f.isAbortError(h))throw this._trackController=null,this._emitError(h),this._clearWaitingTimer(),h;}},0);this._watchId=navigator.geolocation.watchPosition(e=>{this._settingPosition=c(e).catch(f.ignoreAbortErrors)},this._handleWatchPositionError.bind(this),this.geolocationOptions??void 0);this._trackStartingTimeoutId=setTimeout(()=>{this._trackStartingTimeoutId=void 0},15E3)}_handleWatchPositionError(c){c.code=== |
|
c.PERMISSION_DENIED&&this._stopTracking();this._emitError(c)}_abortTrack(){this._trackController?.abort();this._trackController=null}_clearWaitingTimer(){clearTimeout(this._trackStartingTimeoutId);this._trackStartingTimeoutId=void 0;this._settingPosition=null}_emitError(c){this.error=c;this.emit("track-error",{error:c})}};b.__decorate([d.property()],a.prototype,"_watchId",void 0);b.__decorate([d.property()],a.prototype,"_trackStartingTimeoutId",void 0);b.__decorate([d.property()],a.prototype,"_settingPosition", |
|
void 0);b.__decorate([d.property()],a.prototype,"error",void 0);b.__decorate([d.property()],a.prototype,"positionFilterFunction",void 0);b.__decorate([d.property({readOnly:!0})],a.prototype,"state",null);b.__decorate([d.property({readOnly:!0})],a.prototype,"tracking",null);b.__decorate([d.property()],a.prototype,"start",null);b.__decorate([d.property()],a.prototype,"stop",null);return a=b.__decorate([k.subclass("esri.widgets.Track.TrackViewModel")],a)}); |