PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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
  • Implementing the geo-localization tracking
  • Overview
  • Principle and implementation
  • Operating mode according to the use mode of application (foreground or background)
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Managing the geo-localization and the GPS
Overview
WINDEV Mobile and WEBDEV allow you to exploit the geo-localization features and the GPS features found on the telephony devices and on the browsers.
AndroidiPhone/iPadUniversal Windows 10 App In the phone applications, you have the ability to:
  • Get information about the last known device position.
  • Ask to be notified when the device comes near a specific area.
  • Find out the current device position.
  • Retrieve an address.
  • ...
Versions 17 and later
iPhone/iPad Some geo-localization functions can now be used in iPhone/iPad applications.
New in version 17
iPhone/iPad Some geo-localization functions can now be used in iPhone/iPad applications.
iPhone/iPad Some geo-localization functions can now be used in iPhone/iPad applications.
Versions 17 and later
iPhone/iPad Some geo-localization functions can now be used in Universal Windows 10 App mode.
New in version 17
iPhone/iPad Some geo-localization functions can now be used in Universal Windows 10 App mode.
iPhone/iPad Some geo-localization functions can now be used in Universal Windows 10 App mode.
AndroidiPhone/iPad Notes:
Versions 16 and later
WEBDEV - Browser code Some geo-localization functions can now be used in browser code.
WEBDEV - Browser code In the Web sites, you have the ability to interact with the GPS features of the device, if available (mobile device in most cases). In a Web site displayed on a mobile device, you have the ability to retrieve or follow a position.
Caution: The geo-localization is available for the most recent browsers only:
  • FireFox from version 3.5,
  • Chrome from version 5.0.342.1,
  • Opera from version 10.6,
  • Safari from version 5.0.
During the call to a geo-localization function, the browser requests the authorization to localize.
New in version 16
WEBDEV - Browser code Some geo-localization functions can now be used in browser code.
WEBDEV - Browser code In the Web sites, you have the ability to interact with the GPS features of the device, if available (mobile device in most cases). In a Web site displayed on a mobile device, you have the ability to retrieve or follow a position.
Caution: The geo-localization is available for the most recent browsers only:
  • FireFox from version 3.5,
  • Chrome from version 5.0.342.1,
  • Opera from version 10.6,
  • Safari from version 5.0.
During the call to a geo-localization function, the browser requests the authorization to localize.
WEBDEV - Browser code Some geo-localization functions can now be used in browser code.
WEBDEV - Browser code In the Web sites, you have the ability to interact with the GPS features of the device, if available (mobile device in most cases). In a Web site displayed on a mobile device, you have the ability to retrieve or follow a position.
Caution: The geo-localization is available for the most recent browsers only:
  • FireFox from version 3.5,
  • Chrome from version 5.0.342.1,
  • Opera from version 10.6,
  • Safari from version 5.0.
During the call to a geo-localization function, the browser requests the authorization to localize.
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:
// Is the GPS enabled?
IF GPSStatus() = gpsEnabled THEN
Error("The GPS cannot operate.", ...
"It must be enabled to access this application.")
EndProgram()
END

Be notified when the GPS status changes

To be notified when the GPS status changes, all you have to do is call GPSStatus and specify the name of procedure used to manage the current GPS status.
Example:
GPSStatus(_ChangeOfGPSStatus)
The procedure code is as follows:
PROCEDURE _ChangeOfGPSStatus(Status)

IF CurrentStatus = Status THEN RETURN

CurrentStatus = Status

EndTimerSys(TIMER_RETRIEVAL)

SWITCH Status
CASE gpsEnabled
// The provider was enabled by the user.
STC_Status = "GPS enabled"
CASE gpsDisabled
// The provider was disabled by the user.
STC_Status = "GPS disabled"
CASE gpsOffService
// The provider is off service.
STC_Status = "GPS off service"
CASE gpsUnavailable
// The provider is temporarily unavailable.
STC_Status = "GPS unavailable"
CASE gpsAvailable
// The provider is available.
STC_Status = "GPS available"
// Asks to follow the move with a maximum time between two calls to
// GPSFollowMovement(_GetPosition, 1000)
OTHER CASE
END
In this procedure, if the GPS is enabled, a specific procedure is used to follow the movement.
WEBDEV - Browser code This feature is not available.

Following the move

To follow the move of device, all you have to do is call GPSFollowMovement and specify the name of procedure that will be used to manage the move.
Example:
GPSFollowMovement(_GetPosition, 1000)
The code of the procedure can be as follows:
PROCEDURE _GetPosition(MyPosition)

// Update the information about the position
// Latitude and longitude
STC_Latitude = StringBuild("Latitude: %1", MyPosition..Latitude)
STC_Longitude = StringBuild("Longitude: %1", MyPosition..Longitude)

// Speed
IF MyPosition..SpeedValid = True THEN
STC_Speed = StringBuild("Speed: %1 m/s", MyPosition..Speed)
IMG_SPEED_VALIDITY = IMG_OK
ELSE
STC_Speed = "Speed: N/A"
IMG_SPEED_VALIDITY = IMG_NOTOK
END

// Altitude
IF MyPosition..AltitudeValid = True THEN
STC_Altitude = StringBuild("Altitude: %1 m", MyPosition..Altitude)
IMG_ALTITUDE_VALIDITY = IMG_OK
ELSE
STC_Altitude = "Altitude: N/A"
IMG_ALTITUDE_VALIDITY = IMG_NOTOK
END

// Direction
IF MyPosition.DirectionValid = True THEN
STC_Direction = StringBuild("Direction: %1 ° E", MyPosition..Direction)
IMG_DIRECTION_VALIDITY = IMG_OK
ELSE
STC_Direction = "Direction: N/A"
IMG_DIRECTION_VALIDITY = IMG_NOTOK
END

STC_Last_update = StringBuild("Last update on %1 at %2.", ...
DateToString(MyPosition..MeasurementDate..Date), ...
TimeToString(MyPosition..MeasurementDate..Time))
STC_Last_update..Visible = True
In this code, MyPosition is a geoPosition variable. The properties of this type of variable are used to find out the position characteristics.
WEBDEV - Browser code The WLanguage procedure used requires specific parameters.

Ending the use of GPS functions

Depending on the selected setting and on the call frequency, the geo-localization functions can consume a lot of resources on the device (battery, bandwidth, etc.). GPSEnd must be called when the localization functions are no longer used by the application.
WEBDEV - Browser code This feature is not available.
AndroidiPhone/iPad
Versions 21 and later
Implementing the geo-localization tracking

Overview

On a mobile device, it is sometimes necessary to follow the moves of the user even when the mobile application is closed or in background.
This tracking must be performed by consuming as less as possible the resources of the mobile device (especially the battery). This is possible by reducing the precision of tracking in relation to a standard GPS tracking.

Principle and implementation

To manage the tracking:
  1. Enable the tracking with geoTrackingEnable.
  2. Define the procedure called when changing position with geoTrackingProcedure. This function must be used in the initialization process of project.
You can:
Caution: The tracking is a low-precision tracking. The events are sent only if significant changes of position occur and at time intervals exceeding several minutes. For information, the sending conditions per platform are as follows:
  • iPhone/iPad The events regarding the change of position are not sent if the move is less than 500 meters or if the time interval is less than 5 minutes (December 2014).
  • Android The events regarding the change of position are sent with a time interval included between 30 seconds and 10 minutes according to the movement speed.
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.

Operating mode according to the use mode of application (foreground or background)

When the application is in foreground, the procedure supplied to geoTrackingProcedure is automatically called when a position event is received. Any operation of application can be performed in this procedure.
When the application is in background, the application is restarted when position event is received. The initialization process of project is run, then the procedure specified in geoTrackingProcedure.
iPhone/iPad The iOS system limits the operations that can be performed when the application is started in 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 was started in background, use ExeInfo associated with the exeLaunch constant. The exeGeoTracking constant will be returned if the application was started in background by the tracking management.
New in version 21
Implementing the geo-localization tracking

Overview

On a mobile device, it is sometimes necessary to follow the moves of the user even when the mobile application is closed or in background.
This tracking must be performed by consuming as less as possible the resources of the mobile device (especially the battery). This is possible by reducing the precision of tracking in relation to a standard GPS tracking.

Principle and implementation

To manage the tracking:
  1. Enable the tracking with geoTrackingEnable.
  2. Define the procedure called when changing position with geoTrackingProcedure. This function must be used in the initialization process of project.
You can:
Caution: The tracking is a low-precision tracking. The events are sent only if significant changes of position occur and at time intervals exceeding several minutes. For information, the sending conditions per platform are as follows:
  • iPhone/iPad The events regarding the change of position are not sent if the move is less than 500 meters or if the time interval is less than 5 minutes (December 2014).
  • Android The events regarding the change of position are sent with a time interval included between 30 seconds and 10 minutes according to the movement speed.
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.

Operating mode according to the use mode of application (foreground or background)

When the application is in foreground, the procedure supplied to geoTrackingProcedure is automatically called when a position event is received. Any operation of application can be performed in this procedure.
When the application is in background, the application is restarted when position event is received. The initialization process of project is run, then the procedure specified in geoTrackingProcedure.
iPhone/iPad The iOS system limits the operations that can be performed when the application is started in 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 was started in background, use ExeInfo associated with the exeLaunch constant. The exeGeoTracking constant will be returned if the application was started in background by the tracking management.
Implementing the geo-localization tracking

Overview

On a mobile device, it is sometimes necessary to follow the moves of the user even when the mobile application is closed or in background.
This tracking must be performed by consuming as less as possible the resources of the mobile device (especially the battery). This is possible by reducing the precision of tracking in relation to a standard GPS tracking.

Principle and implementation

To manage the tracking:
  1. Enable the tracking with geoTrackingEnable.
  2. Define the procedure called when changing position with geoTrackingProcedure. This function must be used in the initialization process of project.
You can:
Caution: The tracking is a low-precision tracking. The events are sent only if significant changes of position occur and at time intervals exceeding several minutes. For information, the sending conditions per platform are as follows:
  • iPhone/iPad The events regarding the change of position are not sent if the move is less than 500 meters or if the time interval is less than 5 minutes (December 2014).
  • Android The events regarding the change of position are sent with a time interval included between 30 seconds and 10 minutes according to the movement speed.
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.

Operating mode according to the use mode of application (foreground or background)

When the application is in foreground, the procedure supplied to geoTrackingProcedure is automatically called when a position event is received. Any operation of application can be performed in this procedure.
When the application is in background, the application is restarted when position event is received. The initialization process of project is run, then the procedure specified in geoTrackingProcedure.
iPhone/iPad The iOS system limits the operations that can be performed when the application is started in 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 was started in background, use ExeInfo associated with the exeLaunch constant. The exeGeoTracking constant will be returned if the application was started in background by the tracking management.
Functions available according to the platforms

Summary table

The table below presents the different geo-localization and GPS functions as well as the different platforms for which they are currently available (this table can evolve in time):
Functions
Android Android
Versions 17 and later
iPhone/iPad iPhone/iPad
New in version 17
iPhone/iPad iPhone/iPad
iPhone/iPad iPhone/iPad
Universal Windows 10 App Universal Windows App
WEBDEV - Browser code Browser code
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 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 Geo-localization Cross-platform examples (WINDEV Mobile): WM Geo-localization
[ + ] This example explains how to perform proximity searches with geolocalization:
- 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 required version
  • Version 16
This page is also available for…
Comments
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
Nov. 10 2018