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
Products
WINDEVWEBDEV - Server codeWEBDEV - Browser codeWINDEV MobileReports and Queries
Platforms
WindowsLinuxWindows MobileUniversal Windows 10 AppAndroidAndroid Widget iPhone/iPadApple Watch
Languages
JavaPHPAjaxUser code (UMC)External language
Databases
HFSQLHFSQL Client/ServerStored proceduresOLE DBODBCNative Accesses
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.
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 the procedure used to manage the current status of the GPS.
Example:
GPSStatus(_ChangeOfGPSStatus)
The code of the procedure 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 the device, all you have to do is call GPSFollowMovement and specify the name of the procedure 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 all the characteristics of the position.
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.
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
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 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