I am creating a geolocation app with Intel XDK (iPhone and Android) and have 2 questions:
- How can I display the geolocation settings of the device if the GPS is not active on the phone?
- How do I know if the latitude and longitude values returned are from the GPS or from the wifi/data coords? I figured that wifi/data returns a short value
(eg: 43.475748)
and GPS returns a longer value (eg: 43.47573849384)
Am I correct in thinking this?
1.) Most devices will cache the last known geo location. Unfortunately, this behavior is not consistent, and there's not much you can do to change that other than attempt to remember a set of last known locations within your app.
2.) I don't think the HTML5 geo API provides that level of detail, but you could look at the accuracy information that is provided. The designation of "fine" versus "coarse" is somewhat arbritraty, since it means different things on different devices and operating systems (the nature of cross-platform applications). I would use the accuracy feedback as a relative guide.
If you want to play with the geo location feature, checkout the "hello-cordova" sample app in the XDK, it is very easy to use to see how the geo feature works on a variety of devices. You can use it in App Preview or simply build the app and install it on a variety of devices. Note that if you first push the "fine" button then the "watch" button will retrieve "fine" results. If you push the "coarse" button before pushing the "watch" button the watch results will be based on a "coarse" setting.
In general, it is best to first request a "coarse" reading (with a short timeout) to get a general location (or a cached location) and then switch to a "fine" request if you need a more precise location. Battery life will be better if you stick to infrequent "coarse" readings, especially if you only need to know the general location of your user (for example, in which town or neighborhood are they located).