我正在使用Ionic2。
我使用以下代码,但收到错误:
import { Geolocation } from 'ionic-native';
public getPosition(): void {
if (this.markers && this.markers.length > 0) {
var marker: google.maps.Marker = this.markers[0]; // only one
this.latitude = marker.getPosition().lat();
this.longitude = marker.getPosition().lng();
this.getJobRangeSearch(this.searchQuery);
} else {
let options = {
timeout: 10000,
enableHighAccuracy: true
};
Geolocation.getCurrentPosition(options).then((position) => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
this.getJobRangeSearch(this.searchQuery);
}).catch((error) => {
console.log(error);
this.doAlert(error+' Timeout trying to get your devices Location');
});
}
}
错误:
PositionError {message:"超时已过期",代码:3,PERMISSION_DENIED: 1,POSITION_UNAVAILABLE:2,TIMEOUT:3}
的package.json
"ionic-native": "^1.3.2",
谢谢