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


TypeScript Geolocation.watchPosition方法代碼示例

本文整理匯總了TypeScript中ionic-native.Geolocation.watchPosition方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Geolocation.watchPosition方法的具體用法?TypeScript Geolocation.watchPosition怎麽用?TypeScript Geolocation.watchPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ionic-native.Geolocation的用法示例。


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

示例1: startTracking

  startTracking() {
    console.log(":startTracking: ", BackgroundGeolocation);
    let options = {
      frequency: 3000,
      enableHighAccuracy: true
    };

    this.watch = Geolocation.watchPosition(options);

    this.watch.subscribe((data) => {
      alert("latitude: "+data.coords.latitude);
      alert("longitude: "+data.coords.longitude);
      console.log("latitude: "+data.coords.latitude);
      console.log("longitude: "+data.coords.longitude);
      this.notifyLocation(data.coords);
    });

    let backgroundOptions = {
      desiredAccuracy: 10,
      stationaryRadius: 10,
      distanceFilter: 30
    };

    this.backGeolocation.configure((location) => {
      this.notifyLocation(location);
    }, (err) => {
      console.log(err);
    }, backgroundOptions);

    this.backGeolocation.start();

    return this.position;
  }
開發者ID:lucascardoso,項目名稱:app-test-plugins-ionic2,代碼行數:33,代碼來源:location-tracker.ts

示例2: startWatch

 startWatch() {
   this.subscription = Geolocation.watchPosition(this.options).subscribe(position => {
     this.record=true;
     console.log(position);
     this.geo = position;
   });
 }
開發者ID:thgautier92,項目名稱:ionicV2,代碼行數:7,代碼來源:geolocation.ts

示例3: watchPosition

  /**
  * Watch the position
  */
  public watchPosition():void{
    this.isWatching = true;
    this.subscription = Geolocation.watchPosition().subscribe((position) => {

      this.mapsService.getAddress(position.coords.latitude, position.coords.longitude).then((data) => {
        this.address = data[0].formatted_address;
      });

      this.mapsService.moveToPosition(this.map, position.coords.latitude, position.coords.longitude);

    });;
  }
開發者ID:Webaxx,項目名稱:ionic2-geolocation,代碼行數:15,代碼來源:pagehome.ts

示例4:

 Geolocation.getCurrentPosition().then(pos => {
   this.watchGeoID = Geolocation.watchPosition();
   this.watchGeoID.subscribe(
     (data:Geoposition) => {
       // data can be a set of coordinates, or an error (if an error occurred).
       // data.coords.latitude
       // data.coords.longitude
       this.onGeoSuccess(data)
     },
     (err:PositionError) => this.onGeoError('startGeolocation Error: location not available')
   );
 }).catch(err=> {this.onGeoError('startGeolocation Error: location not available')});
開發者ID:FazioNico,項目名稱:ionic-ar-placement,代碼行數:12,代碼來源:geolocation-service.ts

示例5: gpsToggleBrowser

  gpsToggleBrowser(value) {
    if (value) {

      let options = { maximumAge:100, timeout:Infinity, enableHighAccuracy:false};
      
      this.watcher = Geolocation.watchPosition(options).subscribe((data) => {
        
        var obj: any = new Object();
        obj.accuracy = data.coords.accuracy;
        obj.altitude = data.coords.altitude;
        obj.altitudeAccuracy = data.coords.altitudeAccuracy;
        obj.heading = data.coords.heading;
        obj.latitude = data.coords.latitude;
        obj.longitude = data.coords.longitude;
        obj.speed = data.coords.speed;

        let postData: any = JSON.stringify(obj);

        this.userData.setGpsData(postData);
        this.latitude = data.coords.latitude;
        this.longitude = data.coords.longitude;
        this.app.getComponent('tab2').tabBadge++;
 
      })

    } else {

      try {
        this.watcher.unsubscribe();
        this.watcher = null;
      } catch (e) {
        alert('Error unsubscribe: ' + e.statusText);
        console.log(e);
      }

    }
  }
開發者ID:maxamillion32,項目名稱:fleetany-mobile,代碼行數:37,代碼來源:gps.ts


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