【问题标题】:how to get the distance from google, per country如何从每个国家/地区获取与谷歌的距离
【发布时间】:2016-01-26 12:50:07
【问题描述】:

例如德国科隆和比利时泽布吕赫之间的路线。
使用谷歌我可以得到这两个城市之间的总距离,但我真正需要的是每个国家的距离。

在这个例子中,我需要距离:
1. 德国科隆直到与荷兰接壤
2. 与荷兰接壤直到与比利时接壤
3. 与比利时接壤直到比利时泽布吕赫

这是因为您开车经过德国,而不是经过荷兰,最后经过比利时。

如果总距离是 430 公里(错误的数字,只是一个例子),那么我需要类似的东西
1. 德国 200 公里
2. 荷兰 50 公里
3.比利时180公里

这可能来自 c# winforms 应用程序吗? 如果是这样,如何?

【问题讨论】:

    标签: c# winforms google-maps google-maps-api-3


    【解决方案1】:

    虽然您可以在调用Distance Matrix API 时设置国家/地区本身的origindestination,但它不会像您想要的那样详细。以您指定的国家/地区为例

    https://maps.googleapis.com/maps/api/distancematrix/json?origins=Germany&destinations=Belgium
    

    由于默认模式是bicycle(以及其他默认参数),它会给出使用该交通模式的国家(我们不知道具体指向)的总距离

    {
       "destination_addresses" : [ "Belgium" ],
       "origin_addresses" : [ "Germany" ],
       "rows" : [
          {
         "elements" : [
            {
               "distance" : {
                  "text" : "482 km",
                  "value" : 481983
               },
               "duration" : {
                  "text" : "4 days 4 hours",
                  "value" : 360211
               },
               "status" : "OK"
            }
         ]
          }
       ],
       "status" : "OK"
    }
    

    检查了其他 Google API,但这似乎是您能得到的最接近的。

    【讨论】:

      猜你喜欢
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-30
      • 2014-08-12
      • 2011-07-12
      相关资源
      最近更新 更多