Finding the Device Location (GPS) (Magic xpa 2.x)
The ClientOSEnvGet function can also be used to query the current device location using the internal or connected GPS device. The function syntax is as follows:
ClientOSEnvGet ('device_location') – returns the current device location, using any of the available location options (GPS, Network, etc.). The result is a string in the following format: OK|Latitude|Longitude, where OK is a fixed part for testing if a result was returned, and Latitude and Longitude are the coordinates of the current location. If a location could not be obtained, for any reason, an error message will be returned.
Note:
-
Location queries can sometimes take time to respond, because the GPS device is searching for satellites. During this time, the client is blocked, waiting for a response. Developers should make proper indications for the user that this is the situation. Location queries have a built-in timeout of 20 seconds.
-
This operation opens the connection to the GPS and closes it once the data is received. If you need to frequently get the GPS data, you should consider keeping the GPS connection open by writing native code to do so.