0

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

我已经使用以下格式在我的 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>
4

2 回答 2

2

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

<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>

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

于 2016-06-20T08:36:22.647 回答
0

我将航点用于 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'文本中的地址或地址。如果它是文本中的地址,谷歌地图将自行推断纬度

于 2017-07-29T16:28:45.693 回答