[Lazarus] Google geocoding API help

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Google geocoding API help

Free Pascal - Lazarus mailing list
I'm working through how to obtain LAT/LONG for street addresses in the USA and just found GMLib at http://www.cadetill.com/gmlib/  This library is more than I need but I'm working my way through the source to find what I need.

In the meantime I'm asking if anyone knows of a simple how-to or demo or example of just sending a street address through the Goggle API
and just getting back LAT and LONG values. No mapping involved - I'll do that later.

Doug C.





--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Google geocoding API help

Free Pascal - Lazarus mailing list
> In the meantime I'm asking if anyone knows of a simple how-to or demo or
example of just sending a street address through the Goggle API
and just getting back LAT and LONG values

{$H+}

uses
  fphttpclient, fpjson, jsonparser;

var
  Address: String;
  AddressData,LocationData: TJSONObject;
begin
  Write('Enter an address: '); ReadLn(Address);
  AddressData :=
TJSONObject(GetJSON(TFPHTTPClient.SimpleGet('https://maps.googleapis.com/maps/api/geocode/json?address='
+ Address + '&key=well, you have to use your own key, it is not free
unfortunately')));
  LocationData :=
TJSONObject(AddressData.FindPath('results[0].geometry.location'));
  WriteLn('Latitude : ',LocationData.Floats['lat']:1:16);
  WriteLn('Longitude: ',LocationData.Floats['lng']:1:16);
end.

No error checking is intended, I'll leave that up to you.
Get your API key here:
https://developers.google.com/maps/documentation/geocoding/get-api-key



--
Sent from: http://free-pascal-lazarus.989080.n3.nabble.com/
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus