當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript nativescript-background-geolocation-lt.BackgroundGeolocation類代碼示例

本文整理匯總了TypeScript中nativescript-background-geolocation-lt.BackgroundGeolocation的典型用法代碼示例。如果您正苦於以下問題:TypeScript BackgroundGeolocation類的具體用法?TypeScript BackgroundGeolocation怎麽用?TypeScript BackgroundGeolocation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BackgroundGeolocation類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: enabled

 set enabled(value:boolean) {
   console.log('- setEnabled: ', value);
   this.notifyPropertyChange('enabled', value);
   this._enabled = value;
   if (value) {
     BackgroundGeolocation.start();
   } else {
     BackgroundGeolocation.stop();
   }
 }
開發者ID:transistorsoft,項目名稱:nativescript-background-geolocation-lt,代碼行數:10,代碼來源:main-view-model.ts

示例2: onGetCurrentPosition

 public onGetCurrentPosition() {
   BackgroundGeolocation.getCurrentPosition({
     samples: 3,
     persist: true
   }).then((location) => {
     console.log('[getCurrentPosition] -', location);
   }).catch((error) => {
     console.warn('[getCurrentPosition] ERROR -', error);
   });
 }  
開發者ID:transistorsoft,項目名稱:nativescript-background-geolocation-lt,代碼行數:10,代碼來源:main-view-model.ts

示例3: constructor

  constructor() {
    super();

    // First listen to desired events:
    BackgroundGeolocation.on("location", (location) => {
      console.log('[event] location: ', location);
      this.location = JSON.stringify(location, null, 2);
    });
    BackgroundGeolocation.on("motionchange", (isMoving:boolean, location:any) => {
      console.log('[motionchange] -', isMoving, location);
    });
    BackgroundGeolocation.on('http', (response) => {
      console.log('[http] -', response.status, response.responseText);
    });
    BackgroundGeolocation.on('providerchange', (provider) => {
      console.log('[providerchange] -', provider);
    });
    BackgroundGeolocation.on('powersavechange', (isPowerSaveMode) => {
      console.log('[powersavechange] -', isPowerSaveMode);
    });
    BackgroundGeolocation.on('schedule', (state) => {
      console.log('[schedule] -', state.enabled);
    });
    BackgroundGeolocation.on('activitychange', (event) => {
      console.log('[eveactivitychangent] -', event.activity, event.confidence);
    });
    BackgroundGeolocation.on('heartbeat', (event) => {
      console.log('[heartbeat] -', event);
    });
    BackgroundGeolocation.on('geofence', (geofence) => {
      console.log('[geofence] -', geofence);      
    });
    BackgroundGeolocation.on('geofenceschange', (event) => {
      console.log('[geofenceschange] - ON:', JSON.stringify(event.on), ', OFF:', JSON.stringify(event.off));
    });
    BackgroundGeolocation.on('connectivitychange', (event) => {
      console.log('[connectivitychange] -', event);
    });
    BackgroundGeolocation.on('enabledchange', (event) => {
      console.log('[enabledchange] - ', event);
    });
    BackgroundGeolocation.getSensors((sensors) => {
      console.log('[getSensors] -', JSON.stringify(sensors, null, 2));
    });
    BackgroundGeolocation.isPowerSaveMode((mode) => {
      console.log('[isPowerSaveMode] -', mode);
    });
    
    // Now configure the plugin.
    BackgroundGeolocation.ready({
      reset: true,
      debug: true, 
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      distanceFilter: 50,
      stopTimeout: 1,      
      autoSync: true,
      stopOnTerminate: false,
      startOnBoot: true,
      foregroundService: true,
      heartbeatInterval: 60,
      username: 'transistor-ns',
      enableHeadless: true
    }, (state) => {
      console.log('[ready] success -', state);
      this.paceButtonIcon = (state.isMoving) ? ICONS.pause : ICONS.play;
      this.enabled = state.enabled;
    }, (error:string) => {
      console.warn('[ready] FAILURE -', error);
    });
  }
開發者ID:transistorsoft,項目名稱:nativescript-background-geolocation-lt,代碼行數:71,代碼來源:main-view-model.ts

示例4: onChangePace

 public onChangePace() {
   console.log('[changePace] -', this._isMoving);
   this._isMoving = !this._isMoving;
   this.paceButtonIcon = (this._isMoving) ? ICONS.pause : ICONS.play;
   BackgroundGeolocation.changePace(this._isMoving);
 }
開發者ID:transistorsoft,項目名稱:nativescript-background-geolocation-lt,代碼行數:6,代碼來源:main-view-model.ts


注:本文中的nativescript-background-geolocation-lt.BackgroundGeolocation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。