本文整理汇总了TypeScript中ionic-native.Geolocation类的典型用法代码示例。如果您正苦于以下问题:TypeScript Geolocation类的具体用法?TypeScript Geolocation怎么用?TypeScript Geolocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Geolocation类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getGeo
getGeo() {
Geolocation.getCurrentPosition().then(resp=> {
this.latitude = resp.coords.latitude;
this.longitude = resp.coords.longitude;
this.altitude = resp.coords.altitude
})
}
示例3: acquireLocation
private acquireLocation() {
Geolocation.getCurrentPosition().then((resp) => {
console.log('Coordinates are ' + resp.coords.latitude + ',' + resp.coords.longitude);
this.submission.latitude = resp.coords.latitude;
this.submission.longitude = resp.coords.longitude;
});
}
示例4: constructor
constructor(private nav: NavController) {
Geolocation.getCurrentPosition().then((resp) => {
console.log(resp.coords);
//resp.coords.longitude
})
}
示例5: GoogleMapsLatLng
this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
console.log('Map is ready!');
console.log(this.lat + ' ' + this.long);
Geolocation.getCurrentPosition().then(pos => {
console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
this.lat = pos.coords.latitude;
this.long = pos.coords.longitude;
let coord = new GoogleMapsLatLng(this.lat, this.long);
this.map.setCenter(coord);
//this.map.animateCamera({
// 'target': coord,
// 'tilt': 60,
// 'zoom': 18,
// 'bearing': 140
//});
this.map.addMarker({
'position':coord,
'title': "The TagOn Project HeadQuarters"}).then(marker => {
marker.addEventListener(GoogleMapsEvent.INFO_CLICK).subscribe(() => {
console.log("Info window was clicked");
});
});
});
});
示例6: loadMap
loadMap(){
Geolocation.getCurrentPosition().then( (position) => {
console.log(position.coords.latitude+' '+position.coords.longitude);
let cur_location = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let myStyles=[{
featureType: "poi",
elementType: "labels",
stylers: [{ visibility: "off" }]
}];
let mapOptions = {
center: cur_location,
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: myStyles
}
this.map = new google.maps.Map(document.getElementById("map"), mapOptions);
this.marker = new google.maps.Marker({
map: this.map,
draggable: true,
position: cur_location
});
this.map.addListener('click', (event) => {
this.moveMarker(event.latLng);
});
});
}
示例7: setLocation
setLocation(): void {
Geolocation.getCurrentPosition().then((position) => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
this.maps.changeMarker(position.coords.latitude, position.coords.longitude);
let data = {
latitude: this.latitude,
longitude: this.longitude
};
this.dataService.setLocation(data);
let alert = this.alertCtrl.create({
title: 'Location set!',
subTitle: 'You can now find your way back to your camp site from anywhere by clicking the button in the top right corner.',
buttons: [{text: 'Ok'}]
});
alert.present();
});
}
示例8: startWatch
startWatch() {
this.subscription = Geolocation.watchPosition(this.options).subscribe(position => {
this.record=true;
console.log(position);
this.geo = position;
});
}
示例9: findMe
findMe(event) {
Geolocation.getCurrentPosition().then((response) => {
this.lat = response.coords.latitude;
this.long = response.coords.longitude;
this.altitude = response.coords.altitude;
}, (error) => {
console.log("Error: ", error);
});
}
示例10: getPosition
getPosition(){
console.log("click");
Geolocation.getCurrentPosition()
.then(rta =>{
console.log(rta);
})
.catch(error=>{
console.log(error);
})
}