|
Home → WINDEV 25 → WX Informatica - Exemplo de Google Maps com Json retornando Distancia, Tempo e Rota |
WX Informatica - Exemplo de Google Maps com Json retornando Distancia, Tempo e Rota |
Started by BOLLER, Feb., 16 2018 11:14 PM - 8 replies |
| |
| | | |
|
| |
Registered member 3,657 messages Popularité : +175 (223 votes) |
|
Posted on February, 16 2018 - 11:14 PM |
Prezados,
Segue abaixo Exemplo de Google Maps com Json retornando Distancia, Tempo e Rota
Exemplo Usando uma tabela HFSQL
code:wl] GLOBAL gloLatitudeOrigem, gloLongitudeOrigem, gloLatitudeDestino, gloLongitudeDestino, grDistancia, grTempo is real
ST_GoogleMaps is Structure sGoogleMapsName is string sGoogleMapsValue is string END arrGoogle is array of 5000 ST_GoogleMaps
[/code]
Procedure GoogleMapsRotaTable(Origem, Destino, XmlJson)
PersonalJson is Variant
XmlJsonResultado is string
IF Origem <> "" AND Destino = "" THEN Destino = Origem END
ok is boolean = False
IF Origem <> "" AND Destino <> "" ChangeCharset(charsetOccidental) Origem = Capitalize(NoAccent(Origem)) Origem = Replace(Origem," ","+") Destino = Capitalize(NoAccent(Destino)) Destino = Replace(Destino," ","+") HTTPCreateForm("GoogleMaps") HTTPAddParameter("GoogleMaps","origin", Origem) HTTPAddParameter("GoogleMaps","destination", Destino) HTTPAddParameter("GoogleMaps","language", "pt-BR") HTTPAddParameter("GoogleMaps","region", "br") HTTPAddParameter("GoogleMaps","units", "metric") HTTPAddParameter("GoogleMaps","key","AIzaSyDbSVKYPwB1a-_vPbDzAr6LgAfIj4iW2hc") cMyRequest is a httpRequest IF Upper(XmlJson) = "XML" cMyRequest..URL = "https://maps.googleapis.com/maps/api/directions/xml" ELSE IF Upper(XmlJson) = "JSON" cMyRequest..URL = "https://maps.googleapis.com/maps/api/directions/json" END cMyRequest..Method = httpGet cMyResponse is a httpResponse = HTTPSendForm("GoogleMaps", cMyRequest) IF cMyResponse..StatusCode <> 200 THEN XmlJsonResultado = "Erro" ELSE PersonalJson = JSONToVariant(cMyResponse.Content) HDeleteAll(GoogleMaps) GoogleMaps.Name = "Status" GoogleMaps.Value01 = PersonalJson.routes[1].geocoder_status HAdd(GoogleMaps) GoogleMaps.Name = "Latitude Norte" GoogleMaps.Value01 = PersonalJson.routes[1].bounds.northeast.lat..Value HAdd(GoogleMaps) GoogleMaps.Name = "Longitude Norte" GoogleMaps.Value01 = PersonalJson.routes[1].bounds.northeast.lng..Value HAdd(GoogleMaps) GoogleMaps.Name = "Latitude Sul" GoogleMaps.Value01 = PersonalJson.routes[1].bounds.southwest.lat..Value HAdd(GoogleMaps) GoogleMaps.Name = "Longitude Sul" GoogleMaps.Value01 = PersonalJson.routes[1].bounds.southwest.lng..Value HAdd(GoogleMaps) GoogleMaps.Name = "Distancia Texto Total" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].distance.text..Value HAdd(GoogleMaps) GoogleMaps.Name = "Distancia Valor Total" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].distance.value..Value grDistancia = GoogleMaps.Value01 HAdd(GoogleMaps) GoogleMaps.Name = "Duracao Texto Total" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].duration.text..Value HAdd(GoogleMaps) GoogleMaps.Name = "Duracao Valor Total" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].duration.value..Value grTempo = GoogleMaps.Value01 HAdd(GoogleMaps) GoogleMaps.Name = "Endereço Completo Inicial" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].start_address..Value HAdd(GoogleMaps) GoogleMaps.Name = "Endereço Inicial Latitude" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].start_location.lat..Value gloLatitudeOrigem = GoogleMaps.Value01 HAdd(GoogleMaps) GoogleMaps.Name = "Endereço Inicial Longitude" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].start_location.lng..Value gloLongitudeOrigem = GoogleMaps.Value01 HAdd(GoogleMaps) GoogleMaps.Name = "Endereço Completo Final" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].end_address..Value HAdd(GoogleMaps) GoogleMaps.Name = "Endereço Final Latitude" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].end_location.lat..Value gloLatitudeDestino = GoogleMaps.Value01 HAdd(GoogleMaps) GoogleMaps.Name = "Endereço Final Longitude" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].end_location.lng..Value gloLongitudeDestino= GoogleMaps.Value01 HAdd(GoogleMaps) i is int = 0 FOR EACH x OF PersonalJson.routes[1].legs[1].steps i+= 1 GoogleMaps.Name = "Step ["+ i +"]" HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Latitude Inicial" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].start_location.lat HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Longitude Inicial" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].start_location.lng HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Latitude Final" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].end_location.lat HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Longitude Final" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].end_location.lng HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Distancia text" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].distance.text HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Distancia value" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].distance.value HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Duracao text" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].duration.text HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Duracao value" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].duration.value HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Instruções de Voz" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].html_instructions HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Points Polyline Endcode Google" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].polyline.points HAdd(GoogleMaps) GoogleMaps.Name = "Step ["+ i +"] Travel Mode" GoogleMaps.Value01 = PersonalJson.routes[1].legs[1].steps[i].travel_mode HAdd(GoogleMaps) END END XmlJsonResultado = "OK" ELSE XmlJsonResultado = "Erro" END
RESULT(XmlJsonResultado)
Resultado Json apos o Httprequest
Resultado após a importação do json para Hfsql
CODIGO DO BOTAO
GoogleMapsRotaTable(EDT_Origem,EDT_Destino,"JSON")
POrigem is geoPosition POrigem..Latitude = gloLatitudeOrigem POrigem..Longitude = gloLongitudeOrigem
MarkerOrigem is Marker MarkerOrigem..Position = POrigem MarkerOrigem..Name = "Origem" MarkerOrigem..Description = "Origem" MapAddMarker(MAP_GoogleMaps,MarkerOrigem)
PDestino is geoPosition PDestino..Latitude = gloLatitudeDestino PDestino..Longitude = gloLongitudeDestino
MarkerDestino is Marker MarkerDestino..Position = PDestino MarkerDestino..Name = "Destino" MarkerDestino..Description = "Destino" MapAddMarker(MAP_GoogleMaps,MarkerDestino)
MapAddItinerary(MAP_GoogleMaps,[POrigem,PDestino],itineraryCar)
BTN_DISTANCIA..Text = "Distancia: "+grDistancia+" km"
BTN_TEMPO..Text = "Tempo: "+grTempo+" min"
RESULTADO FINAL
-- 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, 17 2018 - 12:23 AM |
| |
| |
| | | |
|
| | |
| |
Registered member 3,657 messages Popularité : +175 (223 votes) |
|
Posted on February, 16 2018 - 11:22 PM |
{<10> "geocoded_waypoints" : [<10> {<10> "geocoder_status" : "OK",<10> "partial_match" : true,<10> "place_id" : "ChIJMVMc2jTk3JQR_KS3mkr2lMY",<10> "types" : [ "street_address" ]<10> },<10> {<10> "geocoder_status" : "OK",<10> "place_id" : "Ek5SLiBDbMOhdmlvIE1vbGluYXJpLCAxMDI5IC0gQ2Fww6NvIGRhIEltYnVpYSwgQ3VyaXRpYmEgLSBQUiwgODI4MTAtMjEwLCBCcmFzaWw",<10> "types" : [ "street_address" ]<10> }<10> ],<10> "routes" : [<10> {<10> "bounds" : {<10> "northeast" : {<10> "lat" : -25.4177243,<10> "lng" : -49.209473<10> },<10> "southwest" : {<10> "lat" : -25.4404742,<10> "lng" : -49.2442012<10> }<10> },<10> "copyrights" : "Dados cartográficos ©2018 Google",<10> "legs" : [<10> {<10> "distance" : {<10> "text" : "6,2 km",<10> "value" : 6222<10> },<10> "duration" : {<10> "text" : "13 minutos",<10> "value" : 802<10> },<10> "end_address" : "R. Clávio Molinari, 1029 - Capão da Imbuia, Curitiba - PR, 82810-210, Brasil",<10> "end_location" : {<10> "lat" : -25.4404742,<10> "lng" : -49.209473<10> },<10> "start_address" : "R. Dr. Goulin, 1699 - Alto da Glória, Curitiba - PR, 80040-280, Brasil",<10> "start_location" : {<10> "lat" : -25.4189803,<10> "lng" : -49.2442012<10> },<10> "steps" : [<10> {<10> "distance" : {<10> "text" : "15 m",<10> "value" : 15<10> },<10> "duration" : {<10> "text" : "1 min",<10> "value" : 3<10> },<10> "end_location" : {<10> "lat" : -25.4189929,<10> "lng" : -49.2440539<10> },<10> "html_instructions" : "Siga na direção \u003cb\u003eleste\u003c/b\u003e na \u003cb\u003eR. Dr. Goulin\u003c/b\u003e em direção Ã<SPC> \u003cb\u003eRua Flávio Dallegrave\u003c/b\u003e",<10> "polyline" : {<10> "points" : "rsczCf_qkH@]"<10> },<10> "start_location" : {<10> "lat" : -25.4189803,<10> "lng" : -49.2442012<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "0,1 km",<10> "value" : 144<10> },<10> "duration" : {<10> "text" : "1 min",<10> "value" : 47<10> },<10> "end_location" : {<10> "lat" : -25.4177243,<10> "lng" : -49.2437741<10> },<10> "html_instructions" : "Vire Ã<SPC> \u003cb\u003eesquerda\u003c/b\u003e na \u003cb\u003eR. Pres. Rodrigo Otávio\u003c/b\u003e",<10> "maneuver" : "turn-left",<10> "polyline" : {<10> "points" : "tsczCh~pkHUGa@Ka@G[Eq@IuAK"<10> },<10> "start_location" : {<10> "lat" : -25.4189929,<10> "lng" : -49.2440539<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "0,3 km",<10> "value" : 266<10> },<10> "duration" : {<10> "text" : "1 min",<10> "value" : 54<10> },<10> "end_location" : {<10> "lat" : -25.4179433,<10> "lng" : -49.2411403<10> },<10> "html_instructions" : "Vire Ã<SPC> \u003cb\u003edireita\u003c/b\u003e na 1ª rua transversal para \u003cb\u003eR. Augusto Stresser\u003c/b\u003e",<10> "maneuver" : "turn-right",<10> "polyline" : {<10> "points" : "vkczCp|pkHD_@@[@Y@S@U@e@@K@o@@UDy@@a@HsB@a@@c@"<10> },<10> "start_location" : {<10> "lat" : -25.4177243,<10> "lng" : -49.2437741<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "1,3 km",<10> "value" : 1288<10> },<10> "duration" : {<10> "text" : "2 minutos",<10> "value" : 128<10> },<10> "end_location" : {<10> "lat" : -25.4282871,<10> "lng" : -49.2414666<10> },<10> "html_instructions" : "Vire Ã<SPC> \u003cb\u003edireita\u003c/b\u003e na \u003cb\u003eAv. N. Sra. da Luz\u003c/b\u003e",<10> "maneuver" : "turn-right",<10> "polyline" : {<10> "points" : "bmczCblpkHnAq@RKb@UHEr@_@jAm@`Ag@`@QPIf@QJEHAJAHAPA^@NBPD@@b@VvCrBZX`D|Bf@^ZV`Av@TNvA|@h@VVJXHXDfANV@T?T?VCTC`@Eb@IfAQfAS^M|Bm@ZKVKJGXK@AJENIj@Ul@Y"<10> },<10> "start_location" : {<10> "lat" : -25.4179433,<10> "lng" : -49.2411403<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "0,1 km",<10> "value" : 141<10> },<10> "duration" : {<10> "text" : "1 min",<10> "value" : 28<10> },<10> "end_location" : {<10> "lat" : -25.4276542,<10> "lng" : -49.2405717<10> },<10> "html_instructions" : "Curva acentuada Ã<SPC> \u003cb\u003eesquerda\u003c/b\u003e na rampa de acesso a \u003cb\u003eAv. Victor Ferreira do Amaral\u003c/b\u003e",<10> "polyline" : {<10> "points" : "xmezCdnpkHJSBGBG@C@E?C?A?C?CAECCWGWEKCKEIGGECCEEGGEIGKIOMO"<10> },<10> "start_location" : {<10> "lat" : -25.4282871,<10> "lng" : -49.2414666<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "2,6 km",<10> "value" : 2553<10> },<10> "duration" : {<10> "text" : "4 minutos",<10> "value" : 256<10> },<10> "end_location" : {<10> "lat" : -25.4300114,<10> "lng" : -49.2153913<10> },<10> "html_instructions" : "Continue para \u003cb\u003eAv. Victor Ferreira do Amaral\u003c/b\u003e",<10> "polyline" : {<10> "points" : "xiezCphpkHEICKAAMc@I_@G]CSAQAY@c@NmCJkC?WZ_GF_AR_DR}CJ}CFiABo@BYBUZyE@[VyDH_BJ_BFmAHkA@cABi@B]Bc@L{BFeADgAFiAXoFN_ET}DDw@NyCHaBHkAHq@Bm@Fo@Ai@B_@f@uJP_DJkBHeBNoCNgC"<10> },<10> "start_location" : {<10> "lat" : -25.4276542,<10> "lng" : -49.2405717<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "0,8 km",<10> "value" : 784<10> },<10> "duration" : {<10> "text" : "2 minutos",<10> "value" : 98<10> },<10> "end_location" : {<10> "lat" : -25.4363978,<10> "lng" : -49.2186964<10> },<10> "html_instructions" : "Vire Ã<SPC> \u003cb\u003edireita\u003c/b\u003e na \u003cb\u003eR. Prof. Nivaldo Braga\u003c/b\u003e (placas para \u003cb\u003eUnibrasil\u003c/b\u003e/\u003cb\u003eCemitério Vertical\u003c/b\u003e)",<10> "maneuver" : "turn-right",<10> "polyline" : {<10> "points" : "pxezCdkkkHlBp@`A\\hA`@hAd@`@P^N`A`@h@Rl@Vn@Xp@Xr@Zn@Xn@Xp@Zn@XbBt@`Bt@l@Xl@Zp@Vp@X"<10> },<10> "start_location" : {<10> "lat" : -25.4300114,<10> "lng" : -49.2153913<10> },<10> "travel_mode" : "DRIVING"<10> },<10> {<10> "distance" : {<10> "text" : "1,0 km",<10> "value" : 1031<10> },<10> "duration" : {<10> "text" : "3 minutos",<10> "value" : 188<10> },<10> "end_location" : {<10> "lat" : -25.4404742,<10> "lng" : -49.209473<10> },<10> "html_instructions" : "Vire Ã<SPC> \u003cb\u003eesquerda\u003c/b\u003e na \u003cb\u003eR. Clávio Molinari\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eO destino estará Ã<SPC> esquerda\u003c/div\u003e",<10> "maneuver" : "turn-left",<10> "polyline" : {<10> "points" : "n`gzCz_lkHdAaDbAaDd@mAd@mA`@sAb@sA`@mA`@mAd@oAd@oAjCcIfAaDfAaDdAaD^gA"<10> },<10> "start_location" : {<10> "lat" : -25.4363978,<10> "lng" : -49.2186964<10> },<10> "travel_mode" : "DRIVING"<10> }<10> ],<10> "traffic_speed_entry" : [],<10> "via_waypoint" : []<10> }<10> ],<10> "overview_polyline" : {<10> "points" : "rsczCf_qkH@]UGcASmAOuAKD_@Bu@Bi@FwBRqF@c@nAq@v@a@jE{Br@[r@Wp@Gn@DRFzDjC|DvCzC~BvA|@h@Vp@T`BTl@@l@Cv@IjB[fBa@xCy@b@Sv@]xAo@N[FUAO[Kc@Ia@W[c@W_@IUa@cBEe@?}@v@qPZ_FR}CJ}CJyBFo@~@oORmDHkA@cAFgAP_Dn@gMd@}JTqERmDL_BFo@Ai@B_@nAgV^wGnDnArCfA`A`@hEfBdEhBfH`DzAt@bBp@hCcIjA{ChCcIjA_DrEeNlDkK"<10> },<10> "summary" : "Av. Victor Ferreira do Amaral",<10> "warnings" : [],<10> "waypoint_order" : []<10> }<10> ],<10> "status" : "OK"<10>}<10>
-- 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,657 messages Popularité : +175 (223 votes) |
|
Posted on February, 17 2018 - 12:38 AM |
Exemplo usando Array em vez de Tabela
CODIGO GLOBAL
GLOBAL gsUser, gsPassword is string gloLatitudeOrigem, gloLongitudeOrigem, gloLatitudeDestino, gloLongitudeDestino, grDistancia, grTempo is real ST_GoogleMaps is structure sGoogleMapsName is string sGoogleMapsValue is string END arrGoogle is array of 5000 ST_GoogleMaps
CODIGO DO BOTAO
GoogleMapsRotaArray(EDT_Origem,EDT_Destino,"JSON")
MapDeleteMarker(MAP_GoogleMaps)
MapDeleteAll(MAP_GoogleMaps)
POrigem is geoPosition POrigem..Latitude = gloLatitudeOrigem POrigem..Longitude = gloLongitudeOrigem
MarkerOrigem is Marker MarkerOrigem..Position = POrigem MarkerOrigem..Name = "Origem" MarkerOrigem..Description = "Origem" MapAddMarker(MAP_GoogleMaps,MarkerOrigem)
PDestino is geoPosition PDestino..Latitude = gloLatitudeDestino PDestino..Longitude = gloLongitudeDestino
MarkerDestino is Marker MarkerDestino..Position = PDestino MarkerDestino..Name = "Destino" MarkerDestino..Description = "Destino" MapAddMarker(MAP_GoogleMaps,MarkerDestino)
MapAddItinerary(MAP_GoogleMaps,[POrigem,PDestino],itineraryCar)
BTN_DISTANCIA..Text = "Distancia: "+grDistancia+" km"
BTN_TEMPO..Text = "Tempo: "+grTempo+" min"
PROCEDURE COM ARRAY
Procedure GoogleMapsRotaArray(Origem, Destino, XmlJson)
PersonalJson is Variant
XmlJsonResultado is string
IF Origem <> "" AND Destino = "" THEN Destino = Origem END
ok is boolean = False
IF Origem <> "" AND Destino <> "" ChangeCharset(charsetOccidental) Origem = Capitalize(NoAccent(Origem)) Origem = Replace(Origem," ","+") Destino = Capitalize(NoAccent(Destino)) Destino = Replace(Destino," ","+") HTTPCreateForm("GoogleMaps") HTTPAddParameter("GoogleMaps","origin", Origem) HTTPAddParameter("GoogleMaps","destination", Destino) HTTPAddParameter("GoogleMaps","language", "pt-BR") HTTPAddParameter("GoogleMaps","region", "br") HTTPAddParameter("GoogleMaps","units", "metric") HTTPAddParameter("GoogleMaps","key","AIzaSyDbSVKYPwB1a-_vPbDzAr6LgAfIj4iW2hc") cMyRequest is a httpRequest IF Upper(XmlJson) = "XML" cMyRequest..URL = "https://maps.googleapis.com/maps/api/directions/xml" ELSE IF Upper(XmlJson) = "JSON" cMyRequest..URL = "https://maps.googleapis.com/maps/api/directions/json" END cMyRequest..Method = httpGet cMyResponse is a httpResponse = HTTPSendForm("GoogleMaps", cMyRequest) IF cMyResponse..StatusCode <> 200 THEN XmlJsonResultado = "Erro" ELSE PersonalJson = JSONToVariant(cMyResponse.Content) index is int = 0 index++ arrGoogle[index].sGoogleMapsName = "Status" arrGoogle[index].sGoogleMapsValue = "OK" index++ arrGoogle[index].sGoogleMapsName = "Latitude Norte" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].bounds.northeast.lat..Value index++ arrGoogle[index].sGoogleMapsName = "Longitude Norte" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].bounds.northeast.lng..Value
index++ arrGoogle[index].sGoogleMapsName = "Latitude Sul" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].bounds.southwest.lat..Value
index++ arrGoogle[index].sGoogleMapsName = "Longitude Sul" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].bounds.southwest.lng..Value
index++ arrGoogle[index].sGoogleMapsName = "Distancia Texto Total" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].distance.text..Value grDistancia = arrGoogle[index].sGoogleMapsValue index++ arrGoogle[index].sGoogleMapsName = "Distancia Valor Total" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].distance.value..Value index++ arrGoogle[index].sGoogleMapsName = "Duracao Texto Total" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].duration.text..Value grTempo = arrGoogle[index].sGoogleMapsValue
index++ arrGoogle[index].sGoogleMapsName = "Duracao Valor Total" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].duration.value..Value
index++ arrGoogle[index].sGoogleMapsName = "Endereço Completo Inicial" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].start_address..Value
index++ arrGoogle[index].sGoogleMapsName = "Endereço Inicial Latitude" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].start_location.lat..Value gloLatitudeOrigem = arrGoogle[index].sGoogleMapsValue index++ arrGoogle[index].sGoogleMapsName = "Endereço Inicial Longitude" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].start_location.lng..Value gloLongitudeOrigem = arrGoogle[index].sGoogleMapsValue index++ arrGoogle[index].sGoogleMapsName = "Endereço Completo Final" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].end_address..Value index++ arrGoogle[index].sGoogleMapsName = "Endereço Final Latitude" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].end_location.lat..Value gloLatitudeDestino = arrGoogle[index].sGoogleMapsValue index++ arrGoogle[index].sGoogleMapsName = "Endereço Final Longitude" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].end_location.lng..Value gloLongitudeDestino= arrGoogle[index].sGoogleMapsValue i is int = 0 FOR EACH x OF PersonalJson.routes[1].legs[1].steps i+= 1 index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"]" index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Latitude Inicial" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].start_location.lat index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Longitude Inicial" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].start_location.lng index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Latitude Final" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].end_location.lat index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Longitude Final" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].end_location.lng index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Distancia text" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].distance.text index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Distancia value" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].distance.value index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Duracao text" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].duration.text index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Duracao value" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].duration.value index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Instruções de Voz" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].html_instructions index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Points Polyline Endcode Google" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].polyline.points index++ arrGoogle[index].sGoogleMapsName = "Step ["+ i +"] Travel Mode" arrGoogle[index].sGoogleMapsValue = PersonalJson.routes[1].legs[1].steps[i].travel_mode END END XmlJsonResultado = "OK" ELSE XmlJsonResultado = "Erro" END
RESULT(XmlJsonResultado)
RESULTADO COM ARRAY É IGUAL
ESSE EXEMPLO USOU UMA TABLE DE MEMORIA DO TIPO STRUCTURE
ST_GoogleMaps is Structure sGoogleMapsName is string sGoogleMapsValue is string END arrGoogle is array of 5000 ST_GoogleMaps
OK, Voce pode fazer com isso o que voce fazia com Clarion e Queue Struct
-- 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, 17 2018 - 1:09 AM |
| |
| |
| | | |
|
| | |
| |
Registered member 3,657 messages Popularité : +175 (223 votes) |
|
Posted on February, 17 2018 - 12:40 AM |
PROCEDURE DESENVOLVIDA PELO CLIENTE RICARDO CASSOLATO
Procedure RotasGoogleMaps(enderecoOrigem is geoPosition, enderecoDestino is geoPosition)
GloVoceEnderecoLongo = "ERRO" GloDestinoEnderecoLongo= "ERRO" GloTempoDestino = "" GloDistanciaDestino = "" GloHtmlInstructions = "" GloPoligonalGoogle = "" GloDistanciaCarro = 0 GloTempoCarro = 0 GloNortelatitude = 0 GloNorteLongitute = 0 GloSullatitude = 0 GloSulLongitute = 0
sPosInicial is string = "" sPosFinal is string = ""
sPosInicial = NoSpace(NumToString(enderecoOrigem..Latitude, "2.7f")) + "," + NoSpace(NumToString(enderecoOrigem..Longitude, "2.7f")) sPosFinal = NoSpace(NumToString(enderecoDestino..Latitude, "2.7f")) + "," + NoSpace(NumToString(enderecoDestino..Longitude, "2.7f"))
UrlRotaJson is string = "https://maps.googleapis.com/maps/api/directions/json?origin="+sPosInicial+"&destination="+sPosFinal+"&sensor=false&mode=driving&key="+gGmapsKey cGmRequestJson is httpRequest cGmRequestJson..URL = UrlRotaJson cGmRequestJson..Method = httpGet cGmResponseJson is httpResponse = HTTPSend(UrlRotaJson) IF cGmResponseJson..StatusCode <> 200 THEN RESULT False END ResGoogleMapsJson is ANSI string = cGmResponseJson..Content
vJsonGoogle is Variant = JSONToVariant(ResGoogleMapsJson)
GloVoceEnderecoLongo = vJsonGoogle.routes[1].legs[1].start_address GloDestinoEnderecoLongo = vJsonGoogle.routes[1].legs[1].end_address GloTempoCarro = vJsonGoogle.routes[1].legs[1].duration.value GloTempoDestino = vJsonGoogle.routes[1].legs[1].duration.text GloDistanciaCarro = vJsonGoogle.routes[1].legs[1].distance.value GloDistanciaDestino = vJsonGoogle.routes[1].legs[1].distance.text GloPoligonalGoogle = vJsonGoogle.routes[1].overview_polyline.points GloNortelatitude = vJsonGoogle.routes[1].bounds.northeast.lat GloNorteLongitute = vJsonGoogle.routes[1].bounds.northeast.lng GloSullatitude = vJsonGoogle.routes[1].bounds.southwest.lat GloSulLongitute = vJsonGoogle.routes[1].bounds.southwest.lng RESULT True
-- 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,657 messages Popularité : +175 (223 votes) |
|
Posted on February, 17 2018 - 1:10 AM |
MapDeleteMarker(MAP_GoogleMaps) MapDeleteAll(MAP_GoogleMaps)
-- 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,657 messages Popularité : +175 (223 votes) |
|
Posted on March, 19 2018 - 4:07 PM |
-- 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,657 messages Popularité : +175 (223 votes) |
|
Posted on May, 03 2021 - 4:12 PM |
Exemplo usando o Here outro diferente do Google maps mas que funciona muito bem
//-----------------------------------------------------------------------------------------------------------------------------------------------------// // pega o local correto pelo here // //-----------------------------------------------------------------------------------------------------------------------------------------------------// sUrl = "https://revgeocode.search.hereapi.com/v1/revgeocode?at="+gsLat+","+gsLon+"&apiKey=XYZZZZZZZZZZZZZZZZZ" Res = "" ok = HTTPRequest(sUrl) JsonHere is JSON IF ok=True THEN Res = HTTPGetResult() ELSE RETURN END JsonHere = Res
-- 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,657 messages Popularité : +175 (223 votes) |
|
Posted on May, 03 2021 - 9:14 PM |
PROCEDURE rot_gps(rlatitude,rlongitude) endereco is string arquivo is string=gsdirtemp+GetGUID()+".json" HTTPDestination(arquivo) IF NOT HTTPRequest("https://maps.googleapis.com/maps/api/geocode/json?latlng=[%rlatitude%],[%rlongitude%]&key=[%gschavegoogle%]") THEN RESULT("") END msjson is JSON=fLoadText(arquivo) endereco=msjson.results[1].formatted_address endereco=StringDelete(endereco,", Brazil") fDelete(arquivo) RESULT(endereco)
Exemplo Paulo Viana
-- 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,657 messages Popularité : +175 (223 votes) |
|
Posted on October, 10 2022 - 9:51 PM |
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
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 99949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | | | |
| | |
|