Google Directions Script

The St. Thomas Church (German: Thomaskirche) is a Lutheran church in Leipzig, Germany, located at the western part of the inner city ring road in Leipzig’s central district. Martin Luther preached in the church in 1539. It is associated with several we…


This content originally appeared on DEV Community and was authored by Max Kleiner

The St. Thomas Church (German: Thomaskirche) is a Lutheran church in Leipzig, Germany, located at the western part of the inner city ring road in Leipzig’s central district. Martin Luther preached in the church in 1539. It is associated with several well-known composers, especially Johann Sebastian Bach, who was its Thomaskantor (music director) from 1723 until his death in 1750. The church holds his remains.

function TAddressGeoCodeOSM8(AURL, location, aApikey: string): tlatlong;
var Httpreq: THttpRequestC; httpres: string;
    Body: TMultipartFormBody;
    jsn: TMcJsonItem;
begin
  httpreq:= THttpRequestC.create(self);
  httpreq.headers.add('Accept: application/json; charset=utf-8');
  httpreq.useragent:= USERAGENT4;
  httpreq.SecurityOptions:= [soSsl3, soPct, soIgnoreCertCNInvalid];
  try
    if httpreq.get(Format(AURL,[location])) then begin
       //httpres:= (httpreq.Response.ContentAsString)
       httpres:= (httpreq.Response.ContentAsUTF8String)
       //writeln('conttype '+httpreq.Response.ContentType);
       writ('debug back '+formatJson(httpres));
       jsn:= TMcJsonItem.Create;
       jsn.AsJSON:= httpres;
       result.lat:= jsn.at(0,'lat').asnumber;
       result.long:= jsn.at(0,'lon').asnumber;
       result.descript:= Format('Coords: lat %2.5f  lng %2.5f %s place_id: %d',
                                [result.lat,result.long,jsn.at(0,'display_name').asstring,
                                                        jsn.at(0,'place_id').asinteger]); 
    end else Writeln('APIError '+inttostr(Httpreq.Response.StatusCode2));
    //StrReplace(httpres, '[{', '{');
  finally 
    writeln('Status3: '+gethttpcod(httpreq.Response.statuscode2))
    httpreq.Free;  
    sleep(200)
    jsn.Free;
  end; 
end;

OSM _to: Coords: lat 51.33933 lng 12.37260 Thomaskirche, 18, Thomaskirchhof, Zentrum, Mitte, Leipzig, Sachsen, 04109, Deutschland place_id: 118838745
get geocoords: lat: 51.3393 - lon: 12.3726
mX5🐞 executed: 26/09/2024 09:52:14 Runtime: 0:0:4.38 Memload: 62% use

TDirection is working as a URL Builder:

procedure TDirectionsBtnGoGoogleClick(Sender: TObject);
Var
  LocFrom,LocTo:RNavigateLongLat;
  Long,Lat:Double;
begin
  LocFrom:=RNavigateLongLat.create;
  Locto:=RNavigateLongLat.create;
  Long:=RealFrmDegreeText(EdtLong.Text);
  Lat:= RealFrmDegreeText(EdtLat.Text);
  LocFrom.CreateDec(Long,Lat);
  Long:=RealFrmDegreeText(EdtLong2.Text);
  Lat:= RealFrmDegreeText(EdtLat2.Text);
  LocTo.CreateDec(Long,Lat);
  // { 0 Start 1 End 3 Center }
  EdtGoogleLink.Text:=LocFrom.GoogleLinkDirectionsTo(LocTo, 0);
  LBlCrowFlies.Caption:='Distance as Crow Flys ='+FormatFloat('0.0km',LocTo.MetresFrom(LocFrom)/1000);
  if CBxGoNow.Checked then
     LocFrom.GoGoogleDirectionsTo(LocTo, 0);
end;

Image description

Google Maps helps you discover new places, find directions, and get real-time updates on traffic, public transportation, and more. You can also control your data with privacy settings, use the Google Assistant, and see stories of how people use Google Maps.

Image description

http://www.softwareschule.ch/examples/directions6.txt


This content originally appeared on DEV Community and was authored by Max Kleiner


Print Share Comment Cite Upload Translate Updates
APA

Max Kleiner | Sciencx (2024-09-28T16:36:27+00:00) Google Directions Script. Retrieved from https://www.scien.cx/2024/09/28/google-directions-script/

MLA
" » Google Directions Script." Max Kleiner | Sciencx - Saturday September 28, 2024, https://www.scien.cx/2024/09/28/google-directions-script/
HARVARD
Max Kleiner | Sciencx Saturday September 28, 2024 » Google Directions Script., viewed ,<https://www.scien.cx/2024/09/28/google-directions-script/>
VANCOUVER
Max Kleiner | Sciencx - » Google Directions Script. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/28/google-directions-script/
CHICAGO
" » Google Directions Script." Max Kleiner | Sciencx - Accessed . https://www.scien.cx/2024/09/28/google-directions-script/
IEEE
" » Google Directions Script." Max Kleiner | Sciencx [Online]. Available: https://www.scien.cx/2024/09/28/google-directions-script/. [Accessed: ]
rf:citation
» Google Directions Script | Max Kleiner | Sciencx | https://www.scien.cx/2024/09/28/google-directions-script/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.