本文整理汇总了TypeScript中ionic-native.Geolocation.getCurrentPosition方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Geolocation.getCurrentPosition方法的具体用法?TypeScript Geolocation.getCurrentPosition怎么用?TypeScript Geolocation.getCurrentPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.Geolocation
的用法示例。
在下文中一共展示了Geolocation.getCurrentPosition方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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");
});
});
});
});
示例2: constructor
constructor(private nav: NavController) {
Geolocation.getCurrentPosition().then((resp) => {
console.log(resp.coords);
//resp.coords.longitude
})
}
示例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: 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();
});
}
示例5: 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);
});
});
}
示例6: getGeo
getGeo() {
Geolocation.getCurrentPosition().then(resp=> {
this.latitude = resp.coords.latitude;
this.longitude = resp.coords.longitude;
this.altitude = resp.coords.altitude
})
}
示例7: 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);
});
}
示例8: Promise
return new Promise((resolve) => {
Geolocation.getCurrentPosition(this.optionsGeoLoc).then((resp) => {
//console.log(resp);
this.currentLoc = resp;
resolve(this.currentLoc);
}, error => {
this.currentLoc = this.defaultLoc;
resolve(this.currentLoc);
});
});
示例9: updateUserLocation
private updateUserLocation(){
Geolocation.getCurrentPosition().then((resp) => {
this.userInfo.setUserInfo(UserInfoService.PREF_USER_LOCATION_LAT, resp.coords.latitude);
this.userInfo.setUserInfo(UserInfoService.PREF_USER_LOCATION_LON, resp.coords.longitude);
this.firebase.storeUserLocationFromPrefs();
}).catch((error) => {
console.log('Error getting location', error);
});
}
示例10: getPosition
getPosition(){
console.log("click");
Geolocation.getCurrentPosition()
.then(rta =>{
console.log(rta);
})
.catch(error=>{
console.log(error);
})
}