unit GoogleDirForm_mX5_64_2_OSM_21_Generic_Request; interface {uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Edit, FMX.Controls.Presentation; } //Purpose: get coordinates of two points and route directions - TAddressGeoCodeOSM5 //https://www.useragents.me/ const USERAGENT5 = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'+ ' Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0 '; USERAGENT2 = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1'; USERAGENT3 = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'+ ' Chrome/125.0.0.0 Safari/537.3'; // chrome + win USERAGENT4 = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15'+ ' (KHTML, like Gecko) Version/17.4.1 Safari/605.1.1'; USERAGENT1 = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '+ // edge + win '(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.'; OSM_URL = 'https://nominatim.openstreetmap.org/search?format=json&q=%s'; type TDirections = {class(}TForm; var LblFrom: TLabel; lbllong: TLabel; EdtLong: TEdit; LblLat: TLabel; EdtLat: TEdit; BtnGoGoogle: TButton; LblLocation, lbltitle: TLabel; LblTo: TLabel; LblLong2: TLabel; EdtLong2: TEdit; LblLat2: TLabel; EdtLat2: TEdit; LblLocation2: TLabel; EdtGoogleLink: TEdit; CBxGoNow: TCheckBox; LBlCrowFlies, Coords: TLabel; fromlat, fromlong, tolat, tolong: string; procedure TDirectionsEdtFromChange(Sender: TObject); procedure TDirectionsEdtToChange(Sender: TObject); procedure TDirectionsBtnGoGoogleClick(Sender: TObject); procedure TDirectionsFormCreate(Sender: TObject); //private { Private declarations } Procedure TDirectionsEditChangeData(AEdtLong,AEdtLat:TEdit;ALabel:TLabel); //public { Public declarations } //end; var Directions: TDirections; implementation //{$R *.fmx} //uses IsNavUtils; //https://sourceforge.net/projects/maxbox/files/Docu/SourceV5/IsNavUtils2.pas/download { TDirections } 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; procedure TDirectionsEditChangeData(AEdtLong, AEdtLat: TEdit; ALabel: TLabel); Var Loc:RNavigateLongLat; Long,Lat:Double; begin loc:= RNavigateLongLat.create; Long:=RealFrmDegreeText(AEdtLong.Text); Lat:= RealFrmDegreeText(AEdtLat.Text); Loc.CreateDec(Long,Lat); ALabel.caption:=Loc.LocatationText(3); end; procedure TDirectionsEdtFromChange(Sender: TObject); begin TDirectionsEditChangeData(EdtLong,EdtLat,LblLocation); end; procedure TDirectionsEdtToChange(Sender: TObject); begin TDirectionsEditChangeData(EdtLong2,EdtLat2,LblLocation2); end; procedure TDirectionsFormCreate(Sender: TObject); begin TDirectionsEdtFromChange(nil); TDirectionsEdtToChange(nil); LBlCrowFlies.caption:='Distance as Crow Flys:'; writeln('fmx form create..'); end; //--------------------------------weather and geocoordinates section ---------- Const UrlWeatherReport25= 'http://api.openweathermap.org/data/2.5/weather?q=%s&units=metric&APPID'+ '=55013bf3d09cfb0619989a00ed5bed_____yourAPIKey'; GEOCoordREX2 = '"lon":([\d\.-]+).*"lat":([\d\.-]+).*'; type TTlatlong = record lat, long: double; descript: string; end; function TAddressGeoCodeOSM2(faddress: string): tlatlong; var url, res, display: string; jo: TJSONObject; urlid: TIduri; winapi: TWinApiDownload; begin urlid:= TIdURI.create(''); url:= urlid.URLEncode('https://nominatim.openstreetmap.org/search?format=json&q='+ fAddress); writeln(url) winapi:= TWinApiDownload.create; winapi.useragent:= USERAGENT5; //'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1'; winapi.url:= url; writeln('check url: '+itoa(winapi.CheckURL(url))); winapi.download1(res); if (res <> '') and (res <> '[]') then begin //windown.OnWorkStart StrReplace(res, '[{', '{'); jo:= TJSONObject.create4(res); try if jo.getString('place_id') <> ' ' then display:= jo.getstring('display_name'); result.descript:= Format('Coords: lat %2.5f lng %2.5f %s place_id: %d', [jo.getdouble('lat'),jo.getdouble('lon'),display, jo.getint('place_id')]); result.lat:= jo.getdouble('lat'); result.long:= jo.getdouble('lon'); except writeln('Geo E: '+ExceptiontoString(exceptiontype, exceptionparam)); finally jo.Free; urlid.free; winapi.free; end; end else showmessagebig('OSM geo location not found! '); end; procedure TRestOnResponseEvent2(ARestClient: TRestClient; ResponseCode: Integer; const ResponseContent: string); begin writeln('@addr of:'+objtostr(arestclient)); //writeln('response cont: '+responsecontent) writeln('response code: '+itoa(responsecode)); writeln('enabled compression '+botostr(arestclient.EnabledCompression)); writeln('content-encoding:'+arestclient.responseheader['Content-Encoding']); writeln('verifycert: '+botostr(arestclient.verifycert)); end; function TAddressGeoCodeOSM7(const AURL, location: string; map: boolean): tlatlong; var encodURL: string; urlid: TIduri; mapStrm: TStringStream; //jconv:TJSONConverter ; jo: TJSONObject; arest: TRestResource; display, wres: string; begin //datafeed:= 'France'; //encodURL:= Format(URLCountry,[HTTPEncode(Datafeed), APIKEY]); urlid:= TIdURI.create(''); //Format(UrlRestAPI,[location] encodurl:= urlid.URLEncode(Format(AURL,[location])); //writeln(Format(OSM_URL,[location])); with TRestClient.create(self) do begin arest:= Resource(EncodURL); //HttpGet(EncodURL, mapStrm); //WinInet arest.ContentType('application/json; charset=utf-8'); writ('content types '+arest.GetContentTypes); //arest.Authorization('Bearer '+MAPGPT_APIKEY2); arest.header('accept','application/json'); ConnectionType:= hctWinInet; OnResponse:= @TRestOnResponseEvent2; //arest.post(mapStrm) wres:= aRest.get; end; if (wres <> '') and (wres <> '[]') then begin //windown.OnWorkStart StrReplace(wres, '[{', '{'); jo:= TJSONObject.create4(wres); try if jo.getString('place_id') <> ' ' then display:= jo.getstring('display_name'); result.descript:= Format('Coords: lat %2.5f lng %2.5f %s place_id: %d', [jo.getdouble('lat'),jo.getdouble('lon'),display, jo.getint('place_id')]); result.lat:= jo.getdouble('lat'); result.long:= jo.getdouble('lon'); if map then OpenWeb('https://www.latlong.net/c/?lat='+flots(result.lat)+'&long='+flots(result.long)); except writeln('Geo E: '+ExceptiontoString(exceptiontype, exceptionparam)); finally jo.Free; urlid.free; encodURL:= ''; end; end else showmessagebig('OSM geo location not found! '); end; function TestHTTPClassComponentAPIMercado(AURL, location, aApikey: string): tlatlong; var HttpReq1: THttpRequestC; httpres: string; Body: TMultipartFormBody; jsn: TMcJsonItem ; begin HttpReq1:= THttpRequestC.create(self); //HttpReq1.headers.add('Content-Type: multipart/form-data'); HttpReq1.headers.add('Accept:application/json'); HttpReq1.useragent:= USERAGENT5; HttpReq1.SecurityOptions:= [soSsl3, soPct, soIgnoreCertCNInvalid]; try if HttpReq1.get(Format(AURL,[location])) then httpres:= (HttpReq1.Response.ContentAsString) else Writeln('APIError '+inttostr(HttpReq1.Response.StatusCode2)); //StrReplace(result, '[{', '{'); writ(formatJson(httpres)); jsn:= TMcJsonItem.Create; jsn.AsJSON := httpres; result.lat:= jsn.at(0,'lat').asnumber; result.long:= jsn.at(0,'lon').asnumber; finally writeln('Status3: '+gethttpcod(HttpReq1.Response.statuscode2)) HttpReq1.Free; sleep(200) jsn.Free; end; end; 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; function TAddressGeoCodeOSM9(AURL, location, aApikey: string): tlatlong; var Httpreq: THttpRequestC; httpres: string; Body: TMultipartFormBody; jsn: TMcJsonItem; con: TBytes; begin httpreq:= THttpRequestC.create(self); httpreq.headers.add('Accept: application/json; charset=utf-8'); httpreq.useragent:= USERAGENT2; httpreq.SecurityOptions:= [soSsl3, soPct, soIgnoreCertCNInvalid]; try if httpreq.get(Format(AURL,[location])) then begin //httpres:= (httpreq.Response.ContentAsString) con:= httpreq.response.content; //BytesToUnicodeString //httpres:= (Stringof((con))); //BytesToAnsistr(const Bytes: SysUtils.TBytes; const CodePage: Word):str; httpres:= BytesToString_Decode(con, GetCodePage); writeln('bytes to '+((httpres))); //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; function TAddressGeoCodeOSM10(AURL, location, aApikey: string): tlatlong; var Httpreq: TRestRequest; httpres: THttpResponse ; Body: TMultipartFormBody; jsn: TMcJsonItem; con: TBytes; begin httpreq:= TRestRequest.create(true); httpreq.Accept:= 'application/json; charset=utf-8'; httpreq.withheader('useragent', USERAGENT3); Httpreq:= httpreq.domain(Format(AURL,[location])); writeln(httpreq.FullUrl); //httpreq.SecurityOptions:= [soSsl3, soPct, soIgnoreCertCNInvalid]; try //if httpreq.get(Format(AURL,[location])) then begin httpres:= httpreq.get; writeln('resback; '+itoa(httpres.responsecode)); if httpres.responsecode > 300 then begin //httpres:= (httpreq.Response.ContentAsString) //con:= httpreq.response.content; //BytesToUnicodeString //httpres:= (Stringof((con))); //BytesToAnsistr(const Bytes: SysUtils.TBytes; const CodePage: Word):str; //httpres:= BytesToString_Decode(con, GetCodePage); writeln('bytes to '+((httpres.responsestr))); //writeln('conttype '+httpreq.Response.ContentType); writ('debug back '+formatJson(httpres.responsestr)); jsn:= TMcJsonItem.Create; jsn.AsJSON:= httpres.responsestr; 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(httpres.responsecode)); //StrReplace(httpres, '[{', '{'); finally writeln('Status3: '+gethttpcod(httpres.responsecode)) httpreq.Free; sleep(200) jsn.Free; end; end; var latf, lonf: Double; function GEOCoord2PointX(apistr: string): TFloatPoint; begin setdecimalseparator('.') with TPerlRegex.Create do try regex:= GEOCoordREX2; subject:= apistr; if match then begin result.x:= strtofloat(groups[1]) result.y:= strtofloat(groups[2]) end; finally Free; end; end; function GetGeoWeather(const location: string; const UrlRestAPI: string): string; var lStrm: TStringStream; begin lStrm:= TStringStream.Create(''); try try HTTPGet(Format(UrlRestAPI,[location]),lStrm); except //if something wrong try using a backup server. //writeln('html back: '+GetURLAsString('http://api.openweathermap.org')); writeln('OWeather_Map Exception: '+Gethtm(UrlWeatherReport25)) end; lStrm.Seek(0,0); result:= 'GEO_Weather_Report5: '+(lStrm.ReadString(lStrm.Size)); finally lStrm.Free; end; end; //----------------------end weather and geocode section------------------------// procedure loadFMXForm; begin Directions:= TDirections.create(self) with directions do begin Left:= 0; Top:= 0 ; formstyle:= fsstayontop; Caption:= 'Form64 Googel Directions WebForm51' ClientHeight:= 591 ClientWidth:= 756 icon.loadfromresourcename(hinstance, 'XARCHIPELAGO'); //XLINUX'); //'ARCHIPELAGO'); //FormFactor.Width:= 320 //FormFactor.Height:= 480 //FormFactor.Devices:= [Desktop] OnCreate:= @TDirectionsFormCreate; //DesignerMasterStyle:= 0 Show; Lbltitle:= TLabel.create(directions) with lbltitle do begin parent:= directions; setBounds(60, 2, 200, 17); font.style2:= fsbold2; font.color:= clnavy; caption:= 'Google Directions NavUtils5' font.size:= 20; end; LblFrom:= TLabel.create(directions) with lblfrom do begin parent:= directions; //StyledSettings:= [Family, Size, Style] left:= 160; top:= 60; //Scale.X:= 2.000000000000000000 //Scale.Y:= 2.000000000000000000 Width:= 41 Height:= 17 //Size.PlatformDefault:= False //TextSettings.FontColor:= claCrimson font.style2:= fsbold2; caption:= 'From' TabOrder:= 26 end; lbllong:= TLabel.create(directions) with lbllong do begin parent:= directions; left:= 260; top:= 96 Width:= 105; Height:= 17 //Size.PlatformDefault:= False caption:= 'Source Longitude' TabOrder:= 17 end ; EdtLong:= TEdit.create(directions) with edtlong do begin parent:= directions; //Touch.InteractiveGestures:= [LongTap, DoubleTap] TabOrder:= 9 Text:= fromlong; //'7.44744'; //50.9473; // - lon: 6.9503 Cologne//'145 30 30' left:= 424; top:= 88 Width:= 281; Height:= 30 //Size.PlatformDefault:= False OnChange:= @TDirectionsEdtFromChange; end; lbllat:= TLabel.create(directions) with lbllat do begin parent:= directions; left:= 260; top:= 136 Width:= 97; Height:= 17 //PlatformDefault:= False caption:= 'Source Latitude' TabOrder:= 18 end; EdtLat:= TEdit.create(directions) with edtlat do begin parent:= directions; //Touch.InteractiveGestures:= [LongTap, DoubleTap] TabOrder:= 10 Text:= fromlat; //'46.94797' left:= 424; top:= 128 Width:= 281; Height:= 30 //PlatformDefault:= False OnChange:= @TDirectionsEdtFromChange; end; BtnGoGoogle:= TButton.create(directions) with btngogoogle do begin parent:= directions; left:= 369; top:= 392 Width:= 140; Height:= 32 //Size.PlatformDefault:= False TabOrder:= 11 caption:= '&Go to Google..' OnClick:= @TDirectionsBtnGoGoogleClick; end; LblLocation:= TLabel.create(directions) with lbllocation do begin parent:= directions; left:= 160; top:= 176 Width:= 553; Height:= 17 //.PlatformDefault:= False caption:= 'LblLocation' TabOrder:= 19 end; Lblto:= TLabel.create(directions) with lblto do begin parent:= directions; //StyledSettings:= [Family, Size, Style] left:= 160 top:= 250 //Scale.X:= 2.000000000000000000 //Scale.Y:= 2.000000000000000000 Width:= 41 Height:= 17 //Size.PlatformDefault:= False //TextSettings.FontColor:= claCrimson font.style2:= fsbold2; caption:= 'To' TabOrder:= 25 end; LblLong2:= TLabel.create(directions) with lbllong2 do begin parent:= directions; left:= 260; top:= 280 Width:= 105; Height:= 17 //Size.PlatformDefault:= False caption:= 'Dest Longitude' TabOrder:= 16 end; EdtLong2:= TEdit.create(directions) with edtlong2 do begin parent:= directions; //Touch.InteractiveGestures:= [LongTap, DoubleTap] TabOrder:= 7 Text:= toLong; //'7.11161'; //Graz'145.69' 50.9473 left:= 424; top:= 272 Width:= 281; Height:= 30 //Size.PlatformDefault:= False OnChange:= @TDirectionsEdtToChange ; end; LblLat2:= TLabel.create(directions) with lbllat2 do begin parent:= directions; left:= 260; top:= 320 Width:= 97; Height:= 17 //Size.PlatformDefault:= False caption:= 'Dest Latitude' TabOrder:= 15 end ; EdtLat2:= TEdit.create(directions) with edtlat2 do begin parent:= directions; //Touch.InteractiveGestures:= [LongTap, DoubleTap] TabOrder:= 8 Text:= tolat; //'49.27092' //- lon: 15.4168 Graz'-37.55' left:= 424; top:= 312 Width:= 281; Height:= 30 //PlatformDefault:= False OnChange:= @TDirectionsEdtToChange ; end; LblLocation2:= TLabel.create(directions) with lbllocation2 do begin parent:= directions; left:= 160; top:= 360 Width:= 553; Height:= 17 //PlatformDefault:= False caption:= 'LblLocation' TabOrder:= 14 end ; EdtGoogleLink:= TEdit.create(directions) with edtgooglelink do begin parent:= directions; //Touch.InteractiveGestures:= [LongTap, DoubleTap] TabOrder:= 27; left:= 20; top:= 448; Width:= 710 Height:= 28 //Size.PlatformDefault:= False end ; CBxGoNow:= TCheckBox.create(directions) with CBxGoNow do begin parent:= directions; left:= 64; top:= 400 Width:= 273; Height:= 19 checked:= true; //Size.PlatformDefault:= False TabOrder:= 28 caption:= 'Check To See Link In Browser' end; LBlCrowFlies:= TLabel.create(directions) with lblcrowflies do begin parent:= directions; left:= 96; top:= 500 Width:= 601; Height:= 17 //Size.PlatformDefault:= False caption:= 'LBlCrowFlies' TabOrder:= 30 end; Coords:= TLabel.create(directions) with coords do begin parent:= directions; left:= 96; top:= 530 Width:= 601; Height:= 17 caption:= 'GeoCoords: ' end; TDirectionsFormCreate(self); end; end; var WebBrowser1: TWebBrowser; procedure loadWebform; var Form1: TForm; begin Form1:= TForm.create(self); with form1 do begin SetBounds(76,46,1200, 1100) Caption:= 'maXbox5 WinControlWebBrowserFeed_WeatherReport' Color:= clBtnFace Font.Charset:= DEFAULT_CHARSET Font.Color:= clWindowText Font.Name:= 'MS Sans Serif' Font.Style:= [] OldCreateOrder := False //OnShow := @TForm1FormShow; PixelsPerInch:= 96 WebBrowser1:= TWebBrowser.create(form1); with webbrowser1 do begin TWinControl(WebBrowser1).Name:= 'MyWebBrowser5'; //TWinControl(WebBrowser1).loadfromstream('MyWebBrowser1'); TWinControl(WebBrowser1).Parent:= form1; TWinControl(WebBrowser1).setbounds(20,24,962,441) TWinControl(WebBrowser1).color:= clblack; TWinControl(WebBrowser1).Align:= alClient; Silent:= True; //EmbeddedWB1.HostCSS:= FmtCSS; //WebBrowser1.OleObject.Document.bgColor := '#000000'; //(WebBrowser1.Document as TWinControl).Color := clblack; Color:= clblack; //'#000000'; TabOrder:= 0 end; end; form1.show; end; var f_latlong, t_latlong: TLatlong; atext: string; begin //@main setdebugcheck(false); writ('SystemCodePage: '+itoa(SystemCodePage)); writ('lib compiler: '+libcompilerstring); writeln('CPUSpeed '+cpuspeed); //loadFMXForm(); { sr:= GetGeoWeather(removespaces('Melbourne,AU'), UrlWeatherReport25); sr:= GetGeoWeather(removespaces('Bern, CH'), UrlWeatherReport25); writeln(sr) lonf:= GEOCoord2PointX(sr).x latf:= GEOCoord2PointX(sr).y PrintF('Lon: %.4f - Lat: %.4f ',[lonf, latf]) coords.caption:= coords.caption+format(' Lon: %.4f - Lat: %.4f',[lonf,latf]); } //latlong:= TAddressGeoCodeOSM('Gereonswall 66, Cologne, Germany'); writeln(mbversion +' '+version) writeln(itoa(MBVERIALL)); //From___ //f_latlong:= TAddressGeoCodeOSM7(OSM_URL,'Cathedral, Bern, Switzerland',false); f_latlong:= TAddressGeoCodeOSM8(OSM_URL,'Cathedral, Bern, Switzerland','false'); //To___ t_latlong:= TAddressGeoCodeOSM8(OSM_URL, 'Ljubljana, Slovenia', 'false'); t_latlong:= TAddressGeoCodeOSM8(OSM_URL, 'Maribor, Slovenia', 'false'); fromlat:= flots(f_latlong.lat); fromlong:= flots(f_latlong.long); //Bern tolat:= flots(t_latlong.lat); tolong:= flots(t_latlong.long); //Jersey //*) //t_latlong:= (TestHTTPClassComponentAPIMercado(OSM_URL,'Maribor, Slovenia','nokey')); // ----------------------Input From To Example-----------------------------// //fromlat:= '46.9479'; fromlong:= '7.44744'; //Bern //tolat:= '49.1857'; tolong:= '-2.1102'; //St. Jersey //------------------------------------------------------------------- loadFMXForm(); //function TAddressGeoCodeOSM5 is now internal precompiled > V51470 //latlong:= TAddressGeoCodeOSM5('Hauptbahnhof, Graz, Austria'); writeln('OSM _from: '+f_latlong.descript); writeln('OSM _to: '+t_latlong.descript); writeln('get geocoords: '+format(' lat: %.4f - lon: %.4f',[t_latlong.lat,t_latlong.long])); coords.caption:= coords.caption+format(' Dest: lat: %.4f - lon: %.4f',[t_latlong.lat,t_latlong.long]); OpenWeb('https://www.latlong.net/c/?lat='+flots(t_latlong.lat)+'&long='+flots(t_latlong.long)); loadWebform(); //WebBrowser1.Navigate('https://wttr.in/Ljubljana'); WebBrowser1.Navigate('https://wttr.in/Maribor'); //*) end. end. Doc: https://maxbox4.wordpress.com/2024/03/06/geocoding-iv/ https://medium.com/@maxkleiner1/geocoding-iv-572a602f4daa Testunit From Cologne to Graz get geocoords: lat: 50.9473 - lon: 6.9503 Cologne get geocoords: lat: 47.0739 - lon: 15.4168 Graz get geocoords: lat: 46.9479 - lon: 7.44744 Bern get geocoords: lat: 49.27092 - lon 7.11161 St. Ingbert ref: http://www.softwareschule.ch/examples/tripadvisor.txt procedure SIRegister_TRestRequest(CL: TPSPascalCompiler); begin //with RegClassS(CL,'TObject', 'TRestRequest') do with CL.AddClassN(CL.FindClass('TObject'),'TRestRequest') do begin Constructor Create( aIsSSL : boolean);'); Constructor Create1;'); Procedure Free'); Function Domain( aDomain : string) : TRestRequest'); Function Path( aPath : string) : TRestRequest'); Function Param( aKey : string; aValue : string) : TRestRequest'); Function FileParam( aKey : string; aValue : string) : TRestRequest'); Function WithHeader( aName : string; aValue : string) : TRestRequest'); Function WithCredentials( username, password : string) : TRestRequest'); Response', 'THttpResponse', iptr); FullUrl', 'string', iptr); Accept', 'string', iptrw); ContentType', 'string', iptrw); BeforeRequest', 'TBeforeRequest', iptrw); Function Get : THttpResponse'); Function Put( aParams : TStringList) : THttpResponse'); Function Post( aParams : TStringList) : THttpResponse'); Function Delete : THttpResponse'); Function Options : THttpResponse'); end; end;