本文整理汇总了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;
}
示例2: startWatch
startWatch() {
this.subscription = Geolocation.watchPosition(this.options).subscribe(position => {
this.record=true;
console.log(position);
this.geo = position;
});
}
示例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);
});;
}
示例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')});
示例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);
}
}
}