ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Geolocation functions
  • Special cases
  • Required permissions
  • Browsers allowing the geolocation
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Retrieves the information about the last known location of the device.
Example
pos is geoPosition 
pos = GPSLastPosition()
IF ErrorOccurred = False THEN
	Info(" Latitude : " + pos.Latitude)  
	Info(" Longitude : " + pos.Longitude)  
END
Syntax
<Result> = GPSLastPosition()
<Result>: geoPosition variable
Name of the geoPosition variable. This variable contains the information about the last known device position. To find out whether the position failed to be retrieved, use the ErrorOccurred variable.
Remarks

Special cases

  • 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.
  • AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst 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 retrieved corresponds to the device's last known position: it may therefore not correspond to the device's current position if, for example, the device has been moved while the GPS signal was invalid.
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst You can use the MeasurementDate property of the geoPosition variable to determine the date and time at which the position was calculated.
  • AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst 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.
AndroidAndroid Widget

Required permissions

This function changes the permissions required by the application.
Permission required: 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.Accordé THEN
    		// Utilisation possible des fonctions nécessitant la localisation en arrière-plan
    	END
    END
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.

Remarks:
  • 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.
WEBDEV - Browser code

Browsers allowing the geolocation

During the call to a geolocation function, the browser requests a location authorization.
Component: wd300java.dll
Minimum version required
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/28/2025

Send a report | Local help