AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de geolocalización
  • Overview
  • Implementing the GPS management
  • Checking whether the GPS is enabled
  • Be notified when the GPS status changes
  • Position tracking
  • Ending the use of GPS functions
  • Implementing geolocation tracking
  • Overview
  • Principle and implementation
  • Operation according to the mode of use of the application
  • When to use each function?
  • Functions available according to the platforms
  • Summary table
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Overview
WINDEV Mobile and WEBDEV allow you to exploit geolocation and GPS features found on mobile devices and browsers.
AndroidiPhone/iPadIOS WidgetMac Catalyst In phone applications, you can:
  • 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.
  • ...
AndroidiPhone/iPadIOS WidgetMac Catalyst Remarks:
WEBDEV - Código Navegador In the Web sites, you have the ability to interact with the GPS features of the device, if available (mobile device in most cases). You can retrieve or track a location in a website displayed on a mobile device.
During the call to a geolocation function, the browser requests a location authorization.
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 GPS status changes, simply call GPSStatus and specify the name of the procedure that will handle the current GPS status.
Example:
GPSStatus(_ChangementEtatGPS)
The procedure code is as follows:
PROCEDURE _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 GPS is enabled, a specific procedure is used to track the device.
WEBDEV - Código Navegador This feature is not available.

Position tracking

To track the device's location, simply use GPSFollowMovement and specify the name of the procedure that will handle location changes.
Example:
GPSFollowMovement(_RécupèrePosition, 1000)
The code of the procedure can be as follows:
PROCEDURE _GetLocation(MyLocation)
// Update the information about the location
// Latitude and longitude
LIB_Latitude = StringBuild("Latitude: %1", MaPosition.Latitude)
LIB_Longitude = StringBuild("Longitude: %1", MaPosition.Longitude)
// Speed
IF MyLocation.SpeedValid = True THEN
	LIB_Vitesse = StringBuild("Speed: %1 m/s", MaPosition.Vitesse)
	IMG_SPEED_VALIDITY = IMG_OK
ELSE
	LIB_Vitesse = "Speed: N/A"
	IMG_SPEED_VALIDITY = IMG_NOTOK
END
// Altitude
IF MyLocation.AltitudeValid = True THEN
	LIB_ZOrder = StringBuild("ZOrder: %1 m", MaPosition.ZOrder)
	IMG_ALTITUDE_VALIDITY = IMG_OK
ELSE
	LIB_ZOrder = "ZOrder: N/A"
	IMG_ALTITUDE_VALIDITY = IMG_NOTOK
END
// Direction
IF MyLocation.DirectionValid = True THEN
	LIB_Direction = StringBuild("Direction: %1 ° E", MaPosition.Direction)
	IMG_DIRECTION_VALIDITY = IMG_OK
ELSE
	LIB_Direction = "Direction: N/A"
	IMG_DIRECTION_VALIDITY = IMG_NOTOK
END
STC_Last_update = StringBuild("Last update on %1 at %2.", ...
	DateToString(MyLocation.MeasurementDate.Date), ...
	TimeToString(MyLocation.MeasurementDate.Time))
STC_Last_update.Visible = True
In this code, MyLocation is a geoPosition variable. The properties of this type of variable are used to find out the location characteristics.
WEBDEV - Código Navegador The WLanguage procedure used requires specific parameters.

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.
WEBDEV - Código Navegador This feature is not available.
AndroidiPhone/iPadIOS WidgetMac Catalyst
Implementing geolocation tracking

Overview

On a mobile device, you may need to track the user's location even when the application is closed or in the background.
You should be able to set up tracking while using as little resources as possible, especially when it comes to battery. This can be achieved by reducing accuracy, compared to standard GPS tracking.

Principle and implementation

To manage location tracking:
  1. Enable location tracking with geoTrackingEnable.
  2. Define the procedure called when changing the location with geoTrackingProcedure. This function must be used in the initialization process of project.
It is possible to:
Caution: Low precision tracking. The events are sent only if significant changes of location occur and at time intervals exceeding several minutes. For information, the sending conditions per platform are as follows:
  • iPhone/iPadIOS WidgetMac Catalyst The events regarding the change of location are not sent if the location did not change by more than 500 meters, or if the time interval is less than 5 minutes (December 2014).
  • Android Location change events are sent at intervals that range from 30 seconds to 10 minutes, depending on the distance between locations.
For a more precise tracking, you must use GPSFollowMovement. However, this function:
  • requires the application to be started,
  • Android requires the application to be in the foreground,
  • consumes more battery.

Operation according to the mode of use of the application

If the application is already running, the procedure given to geoTrackingProcedure is automatically called when a location event is received. Any operation of application can be performed in this procedure.
When the application is stopped, if a location event is received, the application is restarted in the background. The "Initialization" event of the project is run, then the procedure specified in geoTrackingProcedure.
iPhone/iPadIOS WidgetMac Catalyst iOS limits the operations that can be performed when the application is started in the background. Therefore:
  • The execution of background operation cannot exceed ten seconds.
  • No window can be opened and no interface can be displayed (however, a notification can be sent).
Reminder: To find out whether the application has been launched in the background, use function ExeInfo with constant exeLancement. The exeGeoTracking constant will be returned if the application was started in the background.
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
Android Android
iPhone/iPadIOS WidgetMac Catalyst iPhone/iPad
WEBDEV - Código Navegador Browser code
geoAzimuthXX
geoDistanceXX
geoGetAddressXX
geoGetAreaXXX
geoRunAppXX
geoTrackingDisableXX
geoTrackingEnableXX
geoTrackingProcedureXX
geoTrackingStatusXX
GPSDetectPositionX
GPSEndXX
GPSFollowMovementXXX
GPSGetPositionXXX
GPSInfoX
GPSInitParameterXX
GPSLastPositionXXX
GPSStatusXXX
GPSStopDetectionX
Versión mínima requerida
  • Versión 16
Esta página también está disponible para…
Comentarios
video gpsgetposition
https://youtu.be/4MqAx_qiFts

https://windevdesenvolvimento.blogspot.com/2019/01/dicas-1987-windev-mobile-dicas-14.html


amarildo
16 01 2019
Endereço das coordenadas
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/519-busca-endereco-rota-endereco-das-coordendas-523/read.awp?hl=enderecodascoordenadas

https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/2875-informatica-exemplo-google-maps-com-json-retornando-distancia/read.awp?lastview
BOLLER
10 11 2018

Última modificación: 16/01/2025

Señalar un error o enviar una sugerencia | Ayuda local