Rajeev Kannav Sharma

Posts About

Ionic cordova-Geolocation

02 Apr 2015

  • Install cordova plugin by running this command
  • Try to handle every possible situations like Location services disbaled / Or user don’t allow permission to your application

cordova plugin add org.apache.cordova.geolocation

and Then

.controller('YourCtrl', function (loadingService) {
	loadingService.show        
	var posOptions = {
		timeout: 10000,
		enableHighAccuracy: false
	}
	navigator.geolocation.getCurrentPosition(onPositionSuccess, onPositionError, posOptions)
	function onPositionSuccess(position) {         
		var _position = {
			latitude: position.coords.latitude,
			longitude: position.coords.longitude
		}
    //sucess handler code
    loadingService.hide()
	}
  function onPositionError(error) {
    //error handler code
    loadingService.hide()
  }
})
And if you get stuck… Ask Here

email me rajeevsharma86@gmail.com

Tweet to me at @rajeevkannav.