- Special cases
- Required permissions
- Required application feature
In french: CarteSuitDéplacement
Displays the current location of the device in a Map control and updates the location as it moves.
: This function is available in the Android emulator and in the Android simulator.
// Start movement tracking in the Map control
<Result> = MapFollowMovement(<Map control> [, <Compass> [, <WLanguage procedure>]])
- True if the following of movement was enabled,
- False otherwise. To get more details on the error, use ErrorInfo.
<Map control>: Control name
Name of the Map control to be used. If this parameter corresponds to an empty string (""), the Map control to which the current event belongs will be used.
<Compass>: Optional boolean
- True to enable the compass. A compass is displayed in the Map control to indicate the orientation of the move. This option is available for the devices equipped with an orientation sensor.
- False (default value) to disable the compass.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") called each time a movement notification is received. This procedure has the following format:
PROCEDURE <Procedure name> (<Position>)
where <Position> is a variable of type geoPosition that contains information about the device's location at the time of the notification.
The parameters of this procedure are optional. There is no need to pass parameters to this procedure. Indeed, these parameters are automatically filled during each call.
If this procedure returns False, the map displayed in the Map control will not be refreshed.
If this parameter is not specified, whenever a change of device position is notified, the map displayed in the Map control is automatically centered on the new position.
- To stop following the move, use MapEndOfMove.
- A blue circle may appear around the marker, indicating the current position of the device. This circle is a representation of the level of precision regarding the position. The more it is extended, less precise the position will be. To define the location of the device, the function uses two types of "location providers":
The location provider depends on the location settings of the device when the function is called
- the network of GPS satellites,
- the triangulation performed from the network of mobile and Wi-Fi antennas.
- A certain amount of time may elapse between the call to MapFollowMovement and the actual display of the device location on the map. This time corresponds to the time taken by the location provider (GPS or mobile/Wi-Fi network) to define the current location of the device. Once this position is found, the map control is automatically centered on this one.
The call to this function modifies the permissions required by the application.
Required permission: ACCESS_FINE_LOCATION
This permission allows an application to access a specific location (GPS).
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 PROCEDURE 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 applications to use the geolocation features of the device.
Cross-platform examples (WINDEV Mobile): WM Geolocation
Cross-platform examples (WINDEV Mobile): WM Sports
This page is also available for…