Through the use of the getCurrentPosition
method, we can retrieve a single reference to the device location using GPS coordinates. In this recipe, we'll create the functionality to obtain the current location based on a numeric interval to receive constantly updated information.
We are able to pass through an optional parameter containing various arguments to set up interval and improve accuracy:
First, create a new PhoneGap project named
geoupdate
by running the following command:phonegap create geoupdate com.myapp.geoupdate geoupdate
Add the device platform. You can choose to use Android, iOS, or both:
cordova platform add ios cordova platform add android
Add the
geolocation
plugin by running the following command:phonegap plugin add org.apache.cordova.geolocation
Open
www/index.html
and clean up unnecessary elements; so you have the following:<!DOCTYPE html> <html> <head> <meta charset="utf...