Google 地理编码和距离矩阵差异

Google geocode and distancematrix discrepancies

我正在开发一个使用 google 进行地理编码和计算旅行时间的项目,它主要工作正常,但我在以下情况下看到一些莫名其妙的行为。

使用 google 地图,我可以正确地将 2 个位置之间的路线视为 3.6 英里,但是当我对同一路线使用 google 距离矩阵时,api returns 151 英里。

(google映射 api 从 url 混淆的密钥)

1) 对邮政编码 LN68SD 进行地理编码

https://maps.googleapis.com/maps/api/geocode/json?address=LN68SD&key=MapsAPIKey&region=uk

正确地理编码returns 位置 53.2017314,-0.5642401(英国林肯)

2) 对邮政编码 LN57FB 进行地理编码

https://maps.googleapis.com/maps/api/geocode/json?address=LN57FB&key=MapsAPIKey&region=uk

正确地理编码returns 位置 53.2265083,-0.5246126(英国林肯)

3) 显示两个位置之间的路线:

https://www.google.co.uk/maps/dir/53.2017314,+-0.5642401/53.226509094238281,+-0.52461260557174683

地图正确 returns 3.6 英里,15 分钟

4) 获取两个位置之间的距离矩阵:

https://maps.googleapis.com/maps/api/distancematrix/json?&origins=53.2017314,-0.5642401&destinations=53.2265090942383,-0.524612605571747,UK&key=MapsAPIKey&region=uk&mode=driving&units=imperial

distancematrix 错误地指出位置相距 150 英里 (Lincoln/London)

// 20170523131103
// https://maps.googleapis.com/maps/api/distancematrix/json?&origins=53.2017314,-0.5642401&destinations=53.2265090942383,-0.524612605571747,UK&key=MapsAPIKey&region=uk&mode=driving&units=imperial

{
  "destination_addresses": [
    "99-101 Newington Causeway, London SE1 6BN, UK"
  ],
  "origin_addresses": [
    "1 Chancery Cl, Lincoln LN6, UK"
  ],
  "rows": [
    {
      "elements": [
        {
          "distance": {
            "text": "151 mi",
            "value": 243015
          },
          "duration": {
            "text": "2 hours 53 mins",
            "value": 10354
          },
          "status": "OK"
        }
      ]
    }
  ],
  "status": "OK"
}

您在距离矩阵请求中有一个拼写错误(目的地上的“,UK”)。如果我解决了我 get the expected result ("3.6 mi")

https://maps.googleapis.com/maps/api/distancematrix/json?&origins=53.2017314,-0.5642401&destinations=53.2265090942383,-0.524612605571747&region=uk&mode=driving&units=imperial

{
   "destination_addresses" : [ "Waterside S, Lincoln LN5 7FB, UK" ],
   "origin_addresses" : [ "1 Chancery Cl, Lincoln LN6, UK" ],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "3.6 mi",
                  "value" : 5864
               },
               "duration" : {
                  "text" : "15 mins",
                  "value" : 889
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}