Ich bin derzeit in der Startphase eine App über Ionic Gebäude. Im Moment möchte ich die cordova Geolocation darin implementieren. Dies führt jedoch beim Öffnen zu einem Fehler. Zu Testzwecken verwende ich ionic serve und überprüfe es in 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');
}
})
Gibt es einen Ort, an dem ich einen Fehler gemacht habe, der dieses Problem verursacht?
Haben Sie das Plugin richtig an die App hinzufügen? –
Habe auch ein neues Projekt gemacht und es dort probiert. Running it agains zeigt "plugin cordova-plugin-geolocation bereits installiert auf android" – patrick