- Retrieved properties
- Operating mode in iPhone/iPad
- Required permissions
- Required application feature
- Browsers allowing the geolocation
In french: GPSSuitDéplacement
Requests to be notified periodically of the device's current location.
// Enables a procedure to receive the device's location at regular intervals
PROCEDURE MovementProc(pos is geoPosition)
Info(" Latitude: " + pos.Latitude)
Info(" Longitude: " + pos.Longitude)
Enabling the notification mechanism (in a mobile) Hide the details
GPSFollowMovement(<WLanguage procedure> [, <Timeout> [, <Distance>]])
<WLanguage procedure>: Procedure name
Name of WLanguage procedure called at each notification.
This procedure has the following format:
PROCEDURE <Procedure name>(<Location>)
<Location> is a variable of type geoPosition
that contains information about the device's location at the time of the notification.
<Timeout>: Optional integer or optional Duration
Minimum timeout (in hundredths of a second) between two notifications. If this parameter is not specified, the minimum timeout will be set to 60 seconds.
Remark: This parameter can be:
- an integer corresponding to the number of hundredths of a second,
- a Duration variable,
- the duration in a readable format (e.g., 1 s or 10 ms).
This parameter is ignored.
<Distance>: Optional real
Minimum distance (in meters) between two notifications.
If this parameter is not specified, the minimum distance will be set to 5 meters.
Enabling the notification mechanism in browser code Hide the details
<WLanguage procedure>: Procedure name
Name of WLanguage procedure called at each notification. This procedure has the following format:
PROCEDURE <Procedure name>(<Location>, <Error>)
- <Location> is a variable of type geoPosition that contains information about the device's location at the time of the notification. To determine if a value was assigned to the Speed, Accuracy, Direction or Altitude properties of a geoPosition variable when the location was retrieved, use the SpeedValid, AccuracyValid, DirectionValid and AltitudeValid properties.
- <Error> is an Integer constant corresponding to the error code and that can take the following values:
|gpsErrorOK||No error was detected.|
|gpsErrorPosition||Unable to determine the location (e.g., access provider internal error).|
|gpsErrorRights||The browser has no sufficient rights to use geolocation.|
|gpsErrorTimeout||The location could not be retrieved within the timeout.|
Disabling the notification mechanism
- To determine if a value was assigned to the Speed, Accuracy, Direction or Altitude properties of a geoPosition variable when the location was retrieved, use the SpeedValid, AccuracyValid, DirectionValid and AltitudeValid properties.
- To reinitialize a geoPosition variable, use VariableReset.
- It is recommended to reset the parameters of the location provider with GPSInitParameter before retrieving a location.
- The positioning information that was retrieved corresponds to the last known device location: therefore, they may not correspond to the current device location if the device was moved while the GPS signal was not valid for example. You can use the MeasurementDate property of the geoPosition variable to determine the date and time at which the position was calculated.
- Speed, Accuracy, Direction and Altitude will be specified only if the location provider allows it (otherwise, these properties will take their default value).
The location provider can be configured with GPSInitParameter.
- Geolocation functions can consume a lot of resources on the device (battery, bandwidth, etc.). Therefore, we advise you not de define very small values for the minimum time-out and for the minimum distance between two notifications.
- You can enable location tracking in the background without consuming resources via geoTrackingEnable, geoTrackingDisable, geoTrackingStatus and geoTrackingProcedure. For more details, see Location tracking.
- When generating the application, you can allow GPSFollowMovement to be called when the application is in the background (option "Allow calling GPSFollowMovement and BeaconDetectPrecise when the application is in the background" in the "Configuration" step of the wizard).. In this case, the geolocation will continue when the application runs in the background or when the device is in standby mode. For more details, see Generating an iOS application.
- To stop receiving notifications, call GPSFollowMovement without parameter or call GPSEnd.
Operating mode in iPhone/iPad
When a GPS function is first run, the system requests geolocation permission from the user. If the user refuses, all the GPS functions used in the rest of the application will fail (fatal error).
To re-allow the use of GPS for this application, the system configuration of the application must be modified.
The call to this function modifies the permissions required by the application.
Required permission: ACCESS_FINE_LOCATION.
Android 11 specific case:
This function requires the ACCESS_BACKGROUND_LOCATION permission to access the device's location.
This permission allows using the function when the application is in the background.
If the application needs to use background location:
A window allows users to:
- Manually add the "ACCESS_BACKGROUND_LOCATION" permission in the Android application generation wizard.
- Explicitly request background location permission with PermissionRequest. For example:
INTERNAL PROCÉDURE Callback(p is Permission)
IF p.Granted THEN
// Functions that require background location access can be used
- allow access to the device location while the application is in the background,
- allow access to the location only while the application is in use,
- deny access to the location. The user can also change these permissions at any time in the Android settings.
- Follow Google's guidelines for applications that require background location access. For more details, see https://support.google.com/googleplay/android-developer/answer/9799150. If these conditions are not met (especially user information requirements), applications may not be accepted for publication on Google Play.
- The background location permission should only be requested if the location permission has been granted. Otherwise, PermissionRequest will fail.
- If the option chosen by the user for the background location access request is more restrictive than the option chosen for the location access request, the application will be automatically restarted.
- On devices running Android 10 or earlier, if location permission has been granted to the application, the background location permission will be granted without displaying a window.
Required application feature
When this function is used, an application feature is declared in the application generation wizard.
Required feature: Geolocation
This feature allows the applications to access the geolocation features found on the device or on the computer.
Caution: Android 12 specific case: To execute the procedure called by GPSFollowMovement
when the application is in the background, it is necessary to run a persistent thread (ThreadPersistent
Browsers allowing the geolocation
: Geolocation is only available on certain modern browsers:
- FireFox from version 3.5,
- Chrome from version 5.0.342.1,
- Opera from version 10.6,
- Safari from version 5.0.
During the call to a geolocation function, the browser requests a location authorization.Remark: From Chrome 50 (including on Android), GPSFollowMovement
can only be used on the sites secured via an SSL certificate for example. If the site is not secured, the function returns a result that cannot be used. During the test in local (localhost), the function operates properly.
Android (WINDEV Mobile): Android GPS
[ + ]
This example presents the use of the GPS functions of WLanguage in an Android application.
It is used to retrieve at regular interval:
- The latitude
- The longitude
- The altitude
- The speed
- The direction
Cross-platform examples (WINDEV Mobile): WM Sports
[ + ]
This example is a sport application used to save your performances.
The application calculates the distance, the time, the average speed and the number of calories spent according to the sport.
The run is displayed on a map control via markers and an itinerary.
The example also includes a server part used to synchronize the user data.
This webservice is available in the WEBDEV "WW_Sports" example.
This page is also available for…