PC SOFT
ONLINE REPOSITORY
FOR WINDEVWEBDEV AND WINDEV MOBILE

Home |  | Sign in | English US
WM Android Gps - Exemplo mais simples de pegar Laitude e Longitude do Celular
Published by Boller
in the category Tools
New features



Description
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
Illustrations, screen shots
none
none
User reviews
(To evaluate this resource, click 'Write a review')
Boller
PROCEDURE GPS_BuscaEndereco()

//Site Here Maps = https://developer.here.com/projects/PROD-1a48d00b-5e35-4f20-b50e-72d5dd4f77de

//glo_GpsLatitude = -25.2548
//glo_GpsLongitude = -49.1615

ApiKeyHere is string = "I_FQBhS2Odl8ZHLbLu_cPQzEh2J692-0I27qMgxx8GM"
Url is string = "https://revgeocode.search.hereapi.com/v1/revgeocode?at="+glo_GpsLatitude+","+glo_GpsLongitude+"&apiKey="+ApiKeyHere
Res is string = ""

ok is boolean = HTTPRequest(Url)

JsonHere is JSON = HTTPGetResult()

IF ok=True THEN
Res = JsonHere.items[1].address.label
ELSE
Res = ""
END

RETURN Res
Boller
PRINCIPAIS LINKS SOBRE GPS E MAPS
##################################

https://help.windev.com/en-US/?1000019192&name=Functions_GPS_geo

https://help.windev.com/en-US/?1000019277&name=Managing_geolocation_and_GPS

https://help.windev.com/en-US/?1000019955

BONS ESTUDOS