本文整理匯總了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);
})
}