$ionicPlatform.ready(function() {
/*
var postOptions = { timeout: 50000, enableHighAccuracy: false };
$cordovaGeolocation.getCurrentPosition(postOptions)
.then(function(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
if (lat != undefined) {
// $scope.coords.lat = lat;
// $scope.coords.long = long;
console.log(lat + ' ' + long);
}
}, function(err) {
console.log(angular.toJson(err));
});
*/
});
$scope.pickCurrentLocation = function($cordovaGeolocation, $http) {
dataService.getLoading();
$window.navigator.geolocation.getCurrentPosition(function(position) {
$scope.location = {};
$scope.lat = position.coords.latitude;
$scope.lng = position.coords.longitude;
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng($scope.lat, $scope.lng);
var request = {
latLng: latlng
};
geocoder.geocode(request, function(data, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (data[0] != null) {
$scope.address = data[0].formatted_address;
console.log($scope.address);
// alert("address is: " + data[0].formatted_address);
} else {
$scope.address = "No address available";
console.log($scope.address);
//alert("No address available");
}
}
dataService.closeLoading();
})
$scope.location = position;
console.log(position);
$timeout(dataService.closeLoading(), 2000);
});
}
/*
var postOptions = { timeout: 50000, enableHighAccuracy: false };
$cordovaGeolocation.getCurrentPosition(postOptions)
.then(function(position) {
var lat = position.coords.latitude;
var long = position.coords.longitude;
if (lat != undefined) {
// $scope.coords.lat = lat;
// $scope.coords.long = long;
console.log(lat + ' ' + long);
}
}, function(err) {
console.log(angular.toJson(err));
});
*/
});
$scope.pickCurrentLocation = function($cordovaGeolocation, $http) {
dataService.getLoading();
$window.navigator.geolocation.getCurrentPosition(function(position) {
$scope.location = {};
$scope.lat = position.coords.latitude;
$scope.lng = position.coords.longitude;
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng($scope.lat, $scope.lng);
var request = {
latLng: latlng
};
geocoder.geocode(request, function(data, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (data[0] != null) {
$scope.address = data[0].formatted_address;
console.log($scope.address);
// alert("address is: " + data[0].formatted_address);
} else {
$scope.address = "No address available";
console.log($scope.address);
//alert("No address available");
}
}
dataService.closeLoading();
})
$scope.location = position;
console.log(position);
$timeout(dataService.closeLoading(), 2000);
});
}
0 comments:
Post a Comment