I'm not able to display my location in the view, but using console.log (long) I can see from the console my location. Where can I be going wrong? ' .controller ('GeoCtrl', function ($ scope, $ cordovaGeolocation) {
var posOptions = {
timeout: 10000,
enableHighAccuracy: true
};
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
var lat = position.coords.latitude
var long = position.coords.longitude
console.log(long);
$scope.latitude = lat;
$scope.longitude = long;
}, function (err) {
// error
});
var watchOptions = {
timeout: 3000,
enableHighAccuracy: false // may cause errors if true
};
var watch = $cordovaGeolocation.watchPosition(watchOptions);
watch.then(
null,
function (err) {
// error
},
function (position) {
var lat = position.coords.latitude
var long = position.coords.longitude
$scope.latitude = lat;
$scope.longitude = long;
});
watch.clearWatch();
// OR
$cordovaGeolocation.clearWatch(watch)
.then(function (result) {
// success
}, function (error) {
// error
});
});
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Geolocalização</h1>
</ion-header-bar>
<ion-content ng-controller="GeoCtrl">
{{latitude}},{{longitude}}
</ion-content>
</ion-pane>