在 angularjs 中使用 ngmap 显示两点之间的简单路径

Display a simple path between two points using ngmap in angularjs

我已遵循 ngmap 的 Demo 和 github 文档,但仍然无法使用 "directions" 指令加载其中绘制并连接了两个点的简单地图。 (奇怪的是,尽管我可以使用 "marker" 关键字在我的地图中绘制简单的未连接点)

我已经使用以下格式在我的 index.html 文件中包含了一个 apikey:

<script src="http://maps.google.com/maps/api/js?key=APIKEY"></script>

并在我的模块中添加了 ngMap 作为依赖项。

并在 plunker

中测试了我的代码

我确定我只是错过了教程中一些非常明显的东西。感谢所有帮助并提前致谢。

编辑:

模板代码片段:

<ng-map zoom-to-include-markers="true" >
         <directions
          draggable="true"
          panel=""
          travel-mode=""
          origin="14.600631955983781,120.99075458943844"
          destination="14.600839603150039,120.98217152059078">
        </directions>
        </ng-map>

通过向路线的航路点 属性 添加一个值来解决。

<directions
          draggable="true"
          panel=""
          travel-mode=""
          waypoint = /* insert locations here in between origin and destination */
          origin="14.600631955983781,120.99075458943844"
          destination="14.600839603150039,120.98217152059078">
</directions>

虽然我还没有找到一种方法来仅在地图中路由两个位置。

我在2个位置使用航点的方式如下:

<directions
  draggable="true"
  panel=""
  travel-mode=""
  waypoint = {{ waypoints }}
  origin="14.600631955983781,120.99075458943844"
  destination="14.600839603150039,120.98217152059078">
</directions>

$scope.waypoints = [{
  location: 'lat,lon'
}, {
  location: 'lat,lon'
}]

对于waypoints,位置键可以是'lat,lon'或文本地址。如果它是文本地址,google 地图将自己推断经纬度