PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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
  • 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.
Universal 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.
  • ...
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.

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.

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.
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
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 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 version required
  • Version 16
This page is also available for…
Comments
video gpsgetposition
https://youtu.be/4MqAx_qiFts

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


amarildo
16 Jan. 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 Nov. 2018