Recent

Author Topic: GoogleAPI get street address Lat and Long  (Read 6442 times)

jojo86

  • Jr. Member
  • **
  • Posts: 52
Re: GoogleAPI get street address Lat and Long
« Reply #15 on: March 17, 2019, 09:54:50 pm »
Is it possible to calculate the distance on road between two address?

So do you have an exemple with this option?
No different way, just different endpoint: https://developers.google.com/maps/documentation/distance-matrix/start
Thanx that is the solution !
I did it with distancematrix from Google API default is driving mode.
For more information look at : https://developers.google.com/maps/documentation/distance-matrix/intro#DistanceMatrixRequests
My Code :
Code: Pascal  [Select][+][-]
  1. uses fphttpclient,fpjson,jsonparser;
  2.  
  3. procedure TForm1.FormCreate(Sender: TObject);
  4. var
  5.   ReturnValues: TJSONObject;
  6.   MyStartAddress, MyDestinationAddress: string;
  7. begin
  8.   MyStartAddress:='120+road+cityland+postalcode';
  9.   MyDestinationAddress:='2+street+New+York';
  10. //Use Imperial for Miles and Metric form Kilometers units
  11.   with TJSONObject(GetJSON(TFPHTTPClient.SimpleGet('https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins='+MyStartAddress+'&destinations='+MyDestinationAddress+'&key=XXXXXXXYourGoogleKeyAPI'))) do
  12.     try
  13.       ReturnValues := TJSONObject(FindPath('rows[0].elements[0].distance'));
  14.       showmessage(ReturnValues['text'].AsString);//show the distance default return
  15.     finally
  16.       Free;
  17.     end;
  18. end;  
  19.  


I chat with google support and I can tell you that google cloud is free if you use less than 40 000 requests per month.
Thank you so much !

 

TinyPortal © 2005-2018