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
  • Managing locks
  • 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 information about the current device position.
Example
MaPosition is geoPosition
MaPosition = GPSGetPosition()
// Vérifie validité de la position avec ErreurDétectée
IF ErrorOccurred THEN RETURN
Info(" Latitude : " + MaPosition.Latitude)  
Info(" Longitude : " + MaPosition.Longitude)
WEBDEV - Browser code
// Géolocalisation depuis WEBDEV, une procédure navigateur est appelée.
// Traitement réalisé depuis un bouton ayant comme action "aucune"
GPSGetPosition(ProcNavigateur, 200)
// Procédure navigateur "ProcNavigateur"
PROCEDURE ProcNavigateur(MaPosition is geoPosition, nMonErreur is int)
SWITCH nMonErreur
	CASE gpsErrorOK
		// Aucune erreur n'a été détectée
		PAGE_Page1.SAI_SansNom1 = MaPosition.Altitude + " " + MaPosition.Longitude
	CASE gpsErrorRights
		PAGE_Page1.SAI_SansNom1 = "Le navigateur n'a pas les droits " + ...
				"pour utiliser la géolocalisation (ou site non HTTPS)."
	CASE gpsErrorPosition
		PAGE_Page1.SAI_SansNom1 = "Impossible de déterminer la position " + ...
				"(erreur interne du fournisseur d'accès par exemple)."
	CASE gpsErrorTimeout
		PAGE_Page1.SAI_SansNom1 = ...
			"La position n'a pas pu être récupérée dans le temps imparti."
	OTHER CASE
		PAGE_Page1.SAI_SansNom1 = "Erreur indéterminée"
END
Syntax
WEBDEV - Browser code

Retrieving the information in browser code Hide the details

GPSGetPosition([<WLanguage procedure> [, <Timeout>]])
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure in browser code ("callback") called when the location is retrieved.
This procedure has the following format:
PROCEDURE <Procedure name>(<Position>,<Error>)
where:
  • <Error> is an Integer constant corresponding to the error code and that can take the following values:
    gpsErrorOKNo error was detected.
    gpsErrorPositionUnable to determine the location (e.g., access provider internal error).
    gpsErrorRights
    • The browser has no sufficient rights to use geolocation.
    • The browser is recent and the site is not using the HTTPS secure protocol.
    gpsErrorTimeoutThe location could not be retrieved within the timeout.
<Timeout>: Optional integer or optional Duration
Maximum timeout (in hundredths of a second) for updating the device position.
  • If this timeout ends before the device position is updated, gpsErrorTimeOut is returned in the <Error> parameter of the WLanguage procedure.
  • If this parameter is not specified, the timeout is set to 1 minute.
Note: 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).
Remarks

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.
WEBDEV - Browser code This function is not locking.
Note: To find out the last known position of the device without delay, use the GPSLastPosition function.. 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.
WEBDEV - Browser code

Browsers allowing the geolocation

During the call to a geolocation function, the browser requests a location authorization.Note: As of Chrome 50 (including Android), the function GPSGetPosition function can only be used on secure sites (via an SSL certificate, for example). If the site is not secured, the function returns a result that cannot be used. During the test in local (localhost), the function operates properly.
Business / UI classification: Business Logic
Component: wd300java.dll
Minimum version required
  • Version 15
This page is also available for…
Comments
Exemplo
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/3701-trabalhando-com-gps/read.awp
Boller
13 Mar. 2021
Video GpsGetPosition
https://youtu.be/4MqAx_qiFts

https://windevdesenvolvimento.blogspot.com/2019/01/dicas-1987-windev-mobile-dicas-14.html
amarildo
16 Jan. 2019
GPS Functions
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 Nov. 2018
Video Trajeto Mapa
https://youtu.be/bSk0ysOlacE
amarildo
03 Nov. 2018

Last update: 03/27/2025

Send a report | Local help