当前位置: 首页>>代码示例>>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;未经允许,请勿转载。