Tag: google distancematrix api

Google API距离matrix返回错误的JSON导致VBA

希望有人能把我指向正确的方向。 我有一个从Excel调用的VBA函数来调用从一个邮政编码到另一个邮政编码的距离。 这工作正常,直到现在。 只需要计算荷兰的距离,但不能将查询string限制在一个国家。 现在我有一个邮政编码2151 KD,我用它在我的查询string中作为从或到邮政编码。 喜欢: http://maps.googleapis.com/maps/api/distancematrix/json?origins=1251KD&destinations=1211LW&mode=car&sensor=false (我删除了数字和字母之间的空格)。 当我在浏览器中时,这工作正常。 显示正确的位置和距离。 (Destionation或起源)。 这个查询string是使用这个VBA函数在代码中生成的: Function GetDistance(fromZip As String, toZip As String) As Integer Dim Uri As String: Uri = "http://maps.googleapis.com/maps/api/distancematrix/json?origins={0}&destinations={1}&mode=car&sensor=false" Dim xmlHttp As Object: Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0") Dim Json As Object Dim distance As Double: distance = 0 Uri = Replace(Uri, "{0}", fromZip) Uri = […]