WM Android Gps - Exemplo mais simples de pegar Laitude e Longitude do Celular
https://help.WINDEV.com/en-US/search2.awp?q=android%20gps&mode=user&origin=searchbox
INIT WINDOW
gnCurrentStatus is int
// Initialize the GPS
// Pass via the relevant provider (satellite or triangulation)
// We want the altitude, the speed at high precision while requesting an average quantity of battery)
GPSInitParameter(gpsAuto,gpsAltitude+gpsDirection+gpsSpeed+gpsPrecisionHigh+gpsEnergyMedium)
// Is the GPS enabled?
IF GPSStatus() <> gpsEnabled THEN
Error("The GPS will not operate.","Enable it to access this application.")
ELSE
_ChangeGPSStatus(GPSStatus())
END
// Branch a callback procedure to be called when the status of the GPS changes
GPSStatus(_ChangeGPSStatus)
----------------------------------
CLOSE WINDOW
GPSEND()
----------------------------------
// Summary: <specify the action of the procedure>
// Syntax:
//_ChangeGPSStatus (<nStatus>)
//
// Parameters:
// nStatus: <specify the role of nStatus>
// Return value:
// None
//
// Example:
// Indicate an example.
//
PROCEDURE _ChangeGPSStatus(nStatus)
// Ignores the call if the status was not modified
IF gnCurrentStatus = nStatus THEN
RETURN
END
// Stores the current status
gnCurrentStatus = nStatus
SWITCH nStatus
CASE gpsEnabled // the provider was enabled by the user.
STC_Report = "GPS Enabled"
// Asks to follow the move with a maximum time between two calls to
GPSFollowMovement(_GetPosition,1000)
CASE gpsDisabled // the provider was disabled by the user.
STC_Report = "GPS Disabled"
CASE gpsOffService // the provider is off service.
STC_Report = "GPS off service"
CASE gpsUnavailable // the provider is temporarily unavailable.
STC_Report = "GPS Unavailable"
CASE gpsAvailable // the provider is available.
STC_Report = "GPS available"
// Asks to follow the move with a maximum time between two calls to
GPSFollowMovement(_GetPosition,1000)
END
---------------------------------------------------------------------------------------------------------------------------
// Summary: This procedure is automatically called by the WLanguage function named GPSFollowMovement to notify the new position
// Syntax:
//_GetPosition (<MyPosition> is geoPosition)
//
// Parameters:
// MyPosition (geoPosition): New position given by the GPS
PROCEDURE _GetPosition(MyPosition is a geoPosition)
// 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 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 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 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
---------------------------------------------------------------------------------------------------------------------------------
VARIAVEIS
gnCurrentStatus is int