Google API |距离矩阵

问题描述

我的代码需要帮助。

首先,我的方法是否正确,我使用GoogleDistanceMatrix来获取真实的路线距离,而不仅仅是线性距离?

我想使用地理坐标作为起点和终点地址,但它似乎不起作用:

public double CalculateGoogleDistance(GeoCoordinate from,GeoCoordinate to) {
  DistanceMatrixRequest request = new DistanceMatrixRequest();
  request.Key = "****";

  request.Origins = new Location[] {
    new Location(from)
  };
  request.Destinations = new Location[] {
    new Location(to)
  };

  var response = GoogleApi.GoogleMaps.DistanceMatrix.Query(request);

  return response.Rows.First().Elements.First().Distance.Value;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)