PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Overview
  • Implementing the GPS management
  • Checking whether the GPS is enabled
  • Be notified when the GPS status changes
  • Following the move
  • Ending the use of GPS functions
  • When to use each function?
  • Functions available according to the platforms
  • Summary table
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Managing geolocation and GPS
Overview
WINDEV Mobile and WEBDEV allow you to exploit geolocation and GPS features found on mobile devices and browsers.
Universal Windows 10 App In the phone applications, you have the ability to:
  • Get information about the last known location of the device.
  • Ask to be notified when the device comes near a specific area.
  • Find out the current location of the device.
  • Retrieve an address.
  • ...
Implementing the GPS management

Checking whether the GPS is enabled

To check whether the GPS is enabled, all you have to do is use GPSStatus.
Example:
// Est-ce-que le GPS est actif?
IF GPSStatus() <> gpsEnabled THEN
Error("Le GPS n'est pas en état de fonctionner.", ...
"Veuillez l'activer pour avoir accès à cette application.")
EndProgram()
END

Be notified when the GPS status changes

To be notified when the report of the GPS changes, you just have to use the GPSStatus function by specifying the name of the Procedure that will manage the current report of the GPS.
Example:
GPSStatus(_ChangementEtatGPS)
The procedure code is as follows:
PROCÉDURE _ChangementEtatGPS(Etat)
 
IF EtatActuel = Etat THEN RETURN
 
EtatActuel = Etat
 
EndTimerSys(TIMER_RECUPERATION)
 
SWITCH Etat
CASE gpsEnabled
// Le fournisseur a été activé par l'utilisateur.
LIB_Etat = "GPS activé"
CASE gpsDisabled
// Le fournisseur a été désactivé par l'utilisateur.
LIB_Etat = "GPS désactivé"
CASE gpsOffService
// Le fournisseur est hors-service.
LIB_Etat = "GPS hors-service"
CASE gpsUnavailable
// Le fournisseur est temporairement indisponible.
LIB_Etat = "GPS indisponible"
CASE gpsAvailable
// Le fournisseur est disponible.
LIB_Etat = "GPS disponible"
// Demande à suivre le déplacement avec un temps maximum entre deux appels de
// GPSSuitDéplacement(_RécupèrePosition, 1000)
OTHER CASE
END
In this procedure, if the GPS is enabled, a specific procedure is used to follow the movement.

Following the move

To follow the movement of the device, it is enough to use the GPSFollowMovement function by specifying the name of the Procedure which will manage the movement.
Example:
GPSFollowMovement(_RécupèrePosition, 1000)
The code of the procedure can be as follows:
PROCÉDURE _RécupèrePosition(MaPosition)
 
// Mise à jour des informations sur la position
// Latitude et longitude
LIB_Latitude = StringBuild("Latitude: %1", MaPosition.Latitude)
LIB_Longitude = StringBuild("Longitude: %1", MaPosition.Longitude)
 
// Vitesse
IF MaPosition.VitesseValide = True THEN
LIB_Vitesse = StringBuild("Vitesse: %1 m/s", MaPosition.Vitesse)
IMG_VALIDITE_VITESSE = IMG_OK
ELSE
LIB_Vitesse = "Vitesse: N/A"
IMG_VALIDITE_VITESSE = IMG_PASOK
END
 
// Altitude
IF MaPosition.AltitudeValide = True THEN
LIB_Altitude = StringBuild("Altitude: %1 m", MaPosition.Altitude)
IMG_VALIDITE_ALTITUDE = IMG_OK
ELSE
LIB_Altitude = "Altitude: N/A"
IMG_VALIDITE_ALTITUDE = IMG_PASOK
END
 
// Direction
IF MaPosition.DirectionValide = True THEN
LIB_Direction = StringBuild("Direction: %1 ° E", MaPosition.Direction)
IMG_VALIDITE_DIRECTION = IMG_OK
ELSE
LIB_Direction = "Direction: N/A"
IMG_VALIDITE_DIRECTION = IMG_PASOK
END
 
LIB_Dernière_mise_à_jour = StringBuild("Dernière mise à jour le %1 à %2.", ...
DateToString(MaPosition.Datemesure.PartieDate), ...
TimeToString(MaPosition.Datemesure.PartieHeure))
LIB_Dernière_mise_à_jour.Visible = True
In this code, MyPosition is an Variable of type geoPosition. The properties of this type of variable are used to find out the location characteristics.

Ending the use of GPS functions

Depending on the selected settings and on the call frequency, geolocation functions can consume a lot of resources on the device (battery, bandwidth, etc.). GPSEnd must be called when the location functions are no longer used by the application.
When to use each function?
FunctionWhen to use it? AccuracyEnergy consumption
geoTrackingXXXPermanent tracking of location changes, even when the application is in the background.High accuracy, but the frequency of notifications is low and varies depending on the system. Low
GPSFollowMovementPermanent tracking of location changes when the application is in the foreground.Accuracy according to GPSInitParameter. Consumption according to GPSInitParameter.
GPSDetectPositionNotification of the proximity of a given location when the application is in the foreground. Accuracy according to GPSInitParameter. Consumption according to GPSInitParameter.
GPSGetPositionGet current location at a specific moment when the application is in the foreground. It may take long, depending on the surroundings (inside a building, cloudy day, etc.).Accuracy according to GPSInitParameter. Depends on the number of calls.
GPSLastPositionImmediately get the last known location of the device.Low consumption, since it depends on when the last location was actually retrieved. Also depends on GPSInitParameter. Low consumption.
Functions available according to the platforms

Summary table

The table below presents the different geolocation/GPS functions and the different platforms for which they are currently available (this table can evolve with each version):
Functions
Universal Windows 10 App Universal Windows App
geoAzimuthXX
geoDistanceXXX
Versions 17 and later
geoRunApp
New in version 17
geoRunApp
geoRunApp
XX
Versions 17 and later
geoGetAddress
New in version 17
geoGetAddress
geoGetAddress
XX
Versions 26 and later
geoGetArea
New in version 26
geoGetArea
geoGetArea
XXX
Versions 21 and later
geoTrackingEnable
New in version 21
geoTrackingEnable
geoTrackingEnable
XX
Versions 21 and later
geoTrackingDisable
New in version 21
geoTrackingDisable
geoTrackingDisable
XX
Versions 21 and later
geoTrackingStatus
New in version 21
geoTrackingStatus
geoTrackingStatus
XX
Versions 21 and later
geoTrackingProcedure
New in version 21
geoTrackingProcedure
geoTrackingProcedure
XX
GPSStopDetectionXX
GPSLastPositionXXXX
GPSDetectPositionXX
GPSStatusXXXX
GPSInfoXX
GPSInitParameterXXX
GPSGetPositionXXXX
GPSFollowMovementXXXX
GPSEndXXX
Related Examples:
WM Geolocation Cross-platform examples (WINDEV Mobile): WM Geolocation
[ + ] This example explains how to perform proximity searches with geolocation :
- search around me
- search in a city, at a given address, or close to a specific address.
The results are displayed in a looper and in a map with markers.
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment