PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 25 → WX - Colocando consulta Posição atual da pessoa em um aplicativo móvel com GPS
WX - Colocando consulta Posição atual da pessoa em um aplicativo móvel com GPS
Started by BOLLER, Nov., 02 2017 4:25 PM - 3 replies
Registered member
3,651 messages
Popularité : +175 (223 votes)
Posted on November, 02 2017 - 4:25 PM
Prezados,

Colocando consulta Posição atual da pessoa em um aplicativo móvel com GPS?

R.: Ao abrir a primeira tela defina esse código abaixo

GPSInitParameter(gpsAuto, gpsPrecisionLow + gpsEnergyHigh)
IF GPSStatus() = gpsEnabled THEN
GPSStatus(ProcGPS)
ELSE
Info("A Localização do aparelho está desativada. Ative a Localização nas configurações.")
END


E

// Summary: <specify the procedure action>
// Syntax:
//GPS_PlotarClienteELojas ()
//
// Parameters:
// None
// Return Value:
// None
//
// For instance:
// Indicate an example.
//
Procedure GPS_PlotarClienteELojas()

MapDeleteMarker(GoogleMaps)

MapDeleteAll(GoogleMaps)

ok is boolean = False

nContador is int = 0

rDistancia is real = 0

rMenorDistancia is real = 1000000000000000

STC_Distancias = ""
MarkerCliente..Position.Latitude = grlatitude
MarkerCliente..Position.Longitude = grlongitude
MarkerCliente..Name = "Você"
MarkerCliente..Description = "Você"
MarkerCliente..Image = IMG_ClienteMini

IF grlatitude <> 0 AND grlongitude <> 0
MapAddMarker(GoogleMaps, MarkerCliente)
END

//posicionar
MapDisplayPosition(GoogleMaps,gloMinhaPosicao)
MapGetPosition(GoogleMaps)
GoogleMaps..Zoom = 18


//webservice
WS_Mapa()

HExecuteQuery(QRY_Select_Mapas,hQueryDefault)

FOR EACH QRY_Select_Mapas

IF HFound(QRY_Select_Mapas) = True THEN


nContador+= 1
//pega os valores do parametro e preenche as variaveis

gloLojaPosicao..Latitude = QRY_Select_Mapas.t010_latitude
gloLojaPosicao..Longitude = QRY_Select_Mapas.t010_longitude

MarkerLoja..Position.Latitude = QRY_Select_Mapas.t010_latitude
MarkerLoja..Position.Longitude = QRY_Select_Mapas.t010_longitude
MarkerLoja..Name = "Loja "+QRY_Select_Mapas.t010_filial +" - "+ nContador
MarkerLoja..Description = QRY_Select_Mapas.t010_endereco +", "+ QRY_Select_Mapas.t010_filial
MarkerLoja..ActionClick = ProcAcaoClickinMarker

IF Lower(QRY_Select_Mapas.t010_IconUrl) = "loja01"
MarkerLoja..Image = IMG_loja01Mini
ELSE IF Lower(QRY_Select_Mapas.t010_IconUrl) = "loja02"
MarkerLoja..Image = IMG_loja02Mini
ELSE
MarkerLoja..Image = IMG_loja02Mini
END

rDistancia = geoDistance(gloMinhaPosicao,gloLojaPosicao,geoMeter)

IF rDistancia > 0 AND rMenorDistancia > rDistancia THEN

rMenorDistancia = rDistancia

gloLojaMaisProxima..Latitude = QRY_Select_Mapas.t010_latitude
gloLojaMaisProxima..Longitude = QRY_Select_Mapas.t010_longitude

STC_Distancias += "Loja "+QRY_Select_Mapas.t010_filial +" - "+ QRY_Select_Mapas.t010_endereco +", "+ QRY_Select_Mapas.t010_filial + " " + CR

END

//Cria o icone do taxi na tela em menos de 2s gera todos os 400 veiculos no mapa
MapAddMarker(GoogleMaps, MarkerLoja)

//info(QRY_Select_Mapas.t010_latitude, QRY_Select_Mapas.t010_longitude)

END

END

IF gloMinhaPosicao..Latitude <> 0 AND gloMinhaPosicao..Longitude <> 0

//info(gloMinhaPosicao..Latitude, gloMinhaPosicao..Longitude)

MapDisplayPosition(GoogleMaps,gloMinhaPosicao)

MapGetPosition(GoogleMaps)

END

GoogleMaps..Zoom = 12



e


// Summary: <specify the procedure action>
// Syntax:
//WS_Mapa ()
//
// Parameters:
// None
// Return Value:
// None
//
// For instance:
// Indicate an example.
//
// Empresa: <specify the role of Empresa>
// Matricula: <specify the role of Matricula>
// Senha: <specify the role of Senha>
Procedure WS_Mapa()

IF gbLogado = True THEN

servico1 is ViaVarejoWS.Mapa
servico1.ent = ent


ret1 is MapaResponse = WebserviceLoja.Mapa(servico1)

lo is a cLocalidade

gloStatus = ret1.MapaResult.status

gloStatusMessage = ret1.MapaResult.statusMessage

Distancia, x is int = 0

PosicaoLoja is geoPosition

HDeleteAll(t010_mapa)

FOR EACH lo OF ret1.MapaResult.localidade.cLocalidade

PosicaoLoja..Latitude = lo.latitude
PosicaoLoja..Longitude = lo.longitude

IF x <= 3
Distancia = geoDistance(gloMinhaPosicao,PosicaoLoja,geoKilometer)
GloTextoDistancia += Distancia + " KM " + lo.filial
END

t010_mapa.t010_endereco = lo.endereco
t010_mapa.t010_filial = lo.filial
t010_mapa.t010_IconUrl = lo.IconUrl
t010_mapa.t010_latitude = lo.latitude
t010_mapa.t010_longitude = lo.longitude
t010_mapa.t010_status = ret1.MapaResult.status
t010_mapa.t010_statusMessage = ret1.MapaResult.statusMessage

IF Length(lo.latitude) > 0 AND Length(lo.longitude) > 0
ok is boolean = HAdd(t010_mapa)
IF ok = False
Info("Erro em T010: "+ErrorInfo()+HErrorInfo)
END
END

END

END

//MultitaskApp(100)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Message modified, November, 02 2017 - 4:27 PM
Registered member
3,651 messages
Popularité : +175 (223 votes)
Posted on February, 08 2018 - 6:22 PM
Procedure ProcGPS(GPS_Status is int)

SWITCH GPS_Status
CASE gpsUnavailable
//ToastDisplay("GPS Indisponível")
CASE gpsEnabled
//ToastDisplay("GPS está ativado")
CASE gpsDisabled
//ToastDisplay("GPS está desabilitado")
CASE gpsAvailable
gloMinhaPosicao = GPSGetPosition(1000,"Obtendo sua localização...")
IF ErrorOccurred = False THEN
GPSEnd()
ELSE
GPSStatus(ProcGPS)
END
ent.latitude = gloMinhaPosicao.Latitude
ent.longitude = gloMinhaPosicao.Longitude
grlatitude = ent.latitude
grlongitude = ent.longitude
//Info(gloMinhaPosicao.Latitude, gloMinhaPosicao.Longitude)
CASE gpsOffService
//ToastDisplay("GPS fora de serviço")
OTHER CASE
//ToastDisplay("GPS está "+ GPS_Status)
END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Registered member
3,651 messages
Popularité : +175 (223 votes)
Posted on February, 08 2018 - 6:27 PM
Procedure GPS_Inicializar()

GPSInitParameter(gpsSatellite,gpsPrecisionHigh +gpsSpeed)

IF GPSStatus() <> gpsEnabled THEN

Popup("Para melhorar a precisão da sua localização, ative o seu GPS","L")

gbStatusGps = False

ELSE
ChangeGPSStatus(GPSStatus())
END

GPSStatus(ChangeGPSStatus)




Procedure ChangeGPSStatus(nStatus)

IF gnCurrentStatus = nStatus THEN
RETURN
END
gnCurrentStatus = nStatus

IF nStatus = gpsEnabled OR nStatus = gpsAvailable THEN

GPSFollowMovement(GetPosition,300) // intervalo de tempo que vai ficar atualizando a movimentação

END
SWITCH nStatus

CASE gpsEnabled
GloGpsAtivado = True
CASE gpsDisabled
GloGpsAtivado = False
gbStatusGps = False
CASE gpsOffService
CASE gpsUnavailable
CASE gpsAvailable
END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Message modified, February, 08 2018 - 6:27 PM
Registered member
3,651 messages
Popularité : +175 (223 votes)
Posted on February, 04 2022 - 12:58 AM
Procedure Proc_GPS_Status(GPS_Status is int)

SWITCH GPS_Status
CASE gpsUnavailable
ToastDisplay("GPS Indisponível")
CASE gpsEnabled
ToastDisplay("GPS está ativado")
CASE gpsDisabled
ToastDisplay("GPS está desabilitado")
CASE gpsAvailable
gloMinhaPosicao = GPSGetPosition(1000,"Obtendo sua localização...")
IF ErrorOccurred = False THEN
GPSEnd()
ELSE
Info(gloMinhaPosicao.Latitude, gloMinhaPosicao.Longitude)
END
CASE gpsOffService
ToastDisplay("GPS fora de serviço")
OTHER CASE
ToastDisplay("Informação Inesperada")
END


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/