• Managing locks
  • Retrieved properties
  • Operating mode in iPhone/iPad
  • Required permissions
  • Required application feature
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Retrieves information about the current device position.
Universal Windows 10 App GPSGetPosition must be executed in a thread.
MyLocation is géoPosition
MyLocation = GPSGetPosition()
// Checks the position validity with ErrorOccurred
IF ErrorOccurred THEN RETURN
Info(" Latitude : " + MyLocation.Latitude) 
Info(" Longitude : " + MyLocation.Longitude)
Universal Windows 10 AppAndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst

Retrieving information about a device (mobile, ...) Hide the details

<Result> = GPSGetPosition([<Timeout> [, <Message>]])
<Result>: geoPosition variable
geoPosition variable containing information about the device position. If the position is invalid, the ErrorOccurred variable is set to True and the error details are returned by ErrorInfo.
Android The PositionValid property of the geoPosition type determines if the position is valid.
<Timeout>: Optional integer or optional Duration
Maximum timeout (in hundredths of a second) for updating the device position.
  • An error occurs if the timeout ends before the position of the device is updated. This error can be detected by the ErrorOccurred variable and the error details can be returned by ErrorInfo.
  • If this parameter is not specified, the timeout is set to 1 minute.
Remark: This parameter can correspond to:
  • 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).
<Message>: Optional character string
Message of hourglass displayed when updating the position.
Remark: This parameter is taken into account only if the call is performed in the main application thread.
Universal Windows 10 App This parameter is ignored.

Managing locks

GPSGetPosition blocks execution until the current device location is retrieved or until the timeout defined by the <Timeout> parameter expires.
If the function is called in the main thread of the application, an hourglass will be displayed during the function execution. The message displayed by the hourglass can be specified via the <Message> parameter.
Otherwise, the execution of secondary thread will be locked during the function execution and no hourglass will be displayed.
Remark: To find out the last known device position without timeout, use GPSLastPosition. Caution, the positioning information that was retrieved may not correspond to the current device position 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.
Universal Windows 10 AppAndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst

Retrieved properties

  • 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.
  • AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst 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).
    AndroidAndroid Widget The location provider can be configured with GPSInitParameter.
iPhone/iPadIOS WidgetMac Catalyst

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.
AndroidAndroid Widget

Required permissions

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:
  • Manually add the "ACCESS_BACKGROUND_LOCATION" permission in the Android application generation wizard.
  • Explicitly request background location permission with PermissionRequest. For example:
    PermissionRequest(permBackgroundLocation, Callback)
    INTERNAL PROCEDURE Callback(p is Permission)
    IF p.Granted THEN
    // Functions that require background location access can be used
A window allows users to:
  • 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 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.
Universal Windows 10 App

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.
Business / UI classification: Business Logic
Component: wd270java.dll
Minimum version required
  • Version 15
This page is also available for…
13 Mar. 2021
Video GpsGetPosition
16 Jan. 2019
GPS Functions
10 Nov. 2018
Video Trajeto Mapa
03 Nov. 2018