【发布时间】:2016-07-09 13:02:36
【问题描述】:
我目前正处于通过 Ionic 构建应用程序的开始阶段。现在我想在其中实现科尔多瓦地理定位。但是,打开它时会一直出错。出于测试目的,我使用 ionic serve 并在 localhost 中检查它。
angular.module('starter', ['ionic','ionic.service.core', 'ui.router'])
.controller('AgeCtrl', function ($scope, $state, $http, $cordovaGeolocation) {
$scope.toggleItem = function (item) {
item.checked = !item.checked;
};
$scope.items = [
{ id: '0-12' },
{ id: '12-18' },
{ id: '18-30' },
{ id: '30-65' },
{ id: '65+' }
];
$scope.time = Date.now();
$scope.weather = $http.get("http://api.openweathermap.org/data/2.5/weather?q=Amsterdam&units=metric&APPID=...").then(function(resp) {
console.log("success", resp);
}, function(err) {
console.log("error");
})
var posOptions = {timeout: 10000, enableHighAccuracy: false};
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
var lat = position.coords.latitude
var long = position.coords.longitude
console.log(lat + ' ' + long)
}, function(err) {
console.log(err)
});
$scope.Confirm = function (){
$state.go('home');
}
})
是否有什么地方我犯了导致这个问题的错误?
【问题讨论】:
-
您是否将插件正确添加到应用程序中?
-
也做了一个新项目并在那里尝试过。再次运行显示“插件cordova-plugin-geolocation已经安装在android上”
标签: javascript cordova ionic-framework geolocation