Reputation: 165
Google has deprecated the methods getCurrentPosition() and watchPosition() from insecure origins. As I am developing an android application using ionic framework I cant use HTTPS. So I tried to use Cordova geolocation plugin but it is also not working. The code snippet of Cordova plugin is
$scope.getLocation = function () {
alert('Get location Called')
var posOptions = {
timeout: 10000,
enableHighAccuracy: false
}
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
alert('getting current position')
var lat = position.coords.latitude
alert(lat)
var long = position.coords.longitude
alert(long)
}, function (err) {
console.log(err)
alert(err.message)
})
}
<button class="button button-full button-assertive" ng-click="getLocation()">
Get Location
</button>
It gives me an error in console.log(err) like
PositionError {message: "Timeout expired", code: 3, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3}
I only want to get the current position of the user. Is there any other way I could use to get the current latitude and longitude?
Upvotes: 0
Views: 1291
Reputation: 11935
If you are testing on device, you can reboot the device once. Also Go to Settings -> Location and security -> Use networks and active it. This should help.
Upvotes: 2