**THIS APP MIGHT NOT WORK ON ANDROID DUE TO NEW SDK CHANGES.
I am trying to find a fix for android. If you purchased this and need a refund send me an email. apologies.
Similar to Ionic Geolocation but with Background Location Updates enabled.
A barebone ionic geolocation application for iOS and Android that reads your phone gps location and displays it. It's all you need to get started on your location based application. I know you can figure it out on your own, but this will save you time, especially when you get stuck :)
I am updating the location and speed every second, you can change this to what you need. I haven't had any luck with using cordova watchPosition so I am doing my own polling here. Speed is displayed in Meters per second. You can now check if Location Service is disabled for your app.
After you install ionic you have to install cordova geolocation plugin.
Check out my other useful starters are here: Great Ionic Starters.
Documentation
- All of the geolocation logic is contained in 'Geolocation' service in
services.js
Two things you can modify in services are the handling of errors and geolocation options
var options = {
enableHighAccuracy: true, // USE HIGH ACCURACY
timeout: 15000, // HOW LONG TO WAIT FOR A RESPONSE
maximumAge: 0 // SET TO ZERO SO NEW VALUES ARE ALWAYS RETURNED
};
function showError(error) {
console.log('Unable to get the location.'); // LOG ERRORS
}
DashCtrl
controller in controllers.js
is used to display the values from geolocation service
- Data is displayed in
tab-dash.html
- Changes to the values are wrapped in
$scope.$apply(function () { }
to enable data binding
- Geolocation data is obtained by calling
Geolocation.checkLocation(callback)
, this function takes a function as parameter to return the value
- You can change the 1000 (1 second) interval polling on this line:
setInterval( function(){ Geolocation.checkLocation( $scope.callback ); }, 1000);
- Call
Geolocation.isGPSEnabled()
to see if Location Service is enabled
Geolocation.getPosition()
returns a result array
return new Array(latitude, longitude, altitude, speed, GPSEnabled);
where you can check the last element to see if GPS is enabled.
Installation
Install Ionic
Open zipped folder in terminal
go to the project folder
- Install Ionic
sudo npm install -g ionic
ionic platform add ios
ionic platform add android
cordova plugin add cordova-plugin-geolocation
cordova plugin add cordova-plugin-mauron85-background-geolocation
ionic emulate ios
ionic run android
(use run if you use genymotion)
- the app will ask you to share your location
- If you are using an emulator you will have to trigger the location manually
Common Issues
- There are some reported issues with nexus phones and speed variable. Try setting enableHighAccuracy to false in the options array. If this doesn't work then there is an incompatibility with cordova geolocation and the new android sdk. I am still trying to resolve this.
- Notification text is set to 'disabled' on android. In the code remove this line from the configuration.
- The payment on this site is processed by Stripe.com and sometimes your bank will decline the charges if they don't recognize it. You can contact your bank or try a different card.
Support
- Leave a comment if you get stuck on anything
- If you email me directly it might get caught in the spam filter
- And Kudos if you leave a Rating! =)
Stay in Touch
Hey there! You'll need to log in
before you can leave a rating here.
There are no ratings for this
starter yet
·
· just now
{{ rating.comment }}
·
· just now
{{ rating.comment }}