Desktop version

Main > Forum > Supplementary > Jobs, Freelance and International collaboration > How to get json file from Google Maps APIs

Forum

Search UsersRules
How to get json file from Google Maps APIs
#1
Active user
Points:: 0
Joined:: Jul 3, 2013

Hi all!
I use Google Maps API with web browser to get distance from 2 positions,  
URL:"https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=Gia%20B%C3%ACnh,%20B%E1%BA%AFc%20Ninh,%20Vi%E1%BB%87t%20Nam&destinations=C%E1%BA%A7u%20Gi%E1%BA%A5­y,%20H%C3%A0%20N%E1%BB%99i,%20Vi%E1%BB%87t%20Nam&key=AIzaSyA8u0Rb8vCXPrPkfVCVkhu763ms-Ne2wa8";

How to use 1C to get data json file

Im trying to code by HTTP Service with JSON POST:

HTTP = New HTTPConnection("maps.googleapis.com",,,,,True);
RequestBodyFile = GetTempFileName();
ResourceLink = "maps/api/distancematrix/json?units=metric&origins=Cầu Giấy, Hà Nội, Việt Nam&destinations=Từ Sơn, Bắc Ninh, Việt Nam&key=AIzaSyA8u0Rb8vCXPrPkfVCVkhu763ms-Ne2wa8"
FileResult = GetTempFileName();
RequestHeaderHTTP = New Map();
HTTP.Post(RequestBodyFile,ResourceLink,FileResult,RequestHeaderHTTP);
AnswerFile = New TextDocument;
AnswerFile.Read(FileResult, TextEncoding.UTF8);
ServerResponseLine = AnswerFile.GetText();
ReaderJSON = New JSONReader;
ReaderJSON.OpenFile(FileResult);
StructureArray = ReadJSON(ReaderJSON);
If StructureArray.status = "OK" AND StructureArray.rows[0].elements[0].status = "OK" Then
 distance = StructureArray.rows[0].elements[0].distance.value/1000;
EndIf;

Please give me an example

Profile
#2
Interested
Points:: 0
Joined:: Dec 4, 2017

Dear Hoang Minh Tri,

Am I right that according to How to use json to get distance 2 positon from Google Maps APIs, you have already found a working example?

Best regards,
Vladimir Gurov

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.