【问题标题】:Calculate journey time between two locations (co-ordinates) using google maps api使用google maps api计算两个位置(坐标)之间的旅程时间
【发布时间】:2017-06-06 12:43:49
【问题描述】:

我有开始和结束位置的坐标。我想计算到达终点所需的总时间。是否有任何谷歌地图静态 api,我将在其中传递起点和终点位置的坐标,作为回报,它将给出从起点到达终点所需的总时间?

google maps static api的一个例子是这样的:

https://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap&markers=color:red%7Clabel:C%7C<longitude>,<lat>?&key=<api key>

这将返回给定坐标的静态地图。

【问题讨论】:

  • 嗨。我认为您需要使用 Google Directions API 而不是 Maps API。请参阅此 linkthis 示例
  • 看来你是对的@Pieter-JanBeeckman.. 非常感谢你????

标签: javascript google-maps google-static-maps


【解决方案1】:

为此,您必须使用Google Directions API

如果您有两个坐标并且您想知道到达一个点所花费的总时间,您可以通过在此查询中将坐标作为参数传递来做到这一点。

https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&key=YOUR_API_KEY

响应将是一个对象,在此对象中将包含此旅程所需的所有数据,即总时间、检查点等

看看this的例子。

【讨论】:

    猜你喜欢
    • 2013-05-21
    • 2017-10-06
    • 1970-01-01
    • 2014-10-21
    • 1970-01-01
    • 2015-03-30
    • 2016-01-01
    • 2013-04-13
    • 1970-01-01
    相关资源
    最近更新 更多