0
我正在使用Ionic2。Geolocation.getCurrentPosition:超时已过期
我使用下面的代码,但得到一个错误:
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: "Timeout expired", code: 3, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3}
的package.json
"ionic-native": "^1.3.2",
谢谢