【问题标题】:Display a simple path between two points using ngmap in angularjs在angularjs中使用ngmap显示两点之间的简单路径
【发布时间】:2016-06-20 06:28:57
【问题描述】:

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

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

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

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

并在plunker中测试了我的代码

我确定我只是遗漏了教程中非常明显的内容。提前感谢所有帮助和感谢。

编辑:

模板代码sn-p:

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

【问题讨论】:

    标签: angularjs google-maps-api-3 direction ng-map


    【解决方案1】:

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

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

      我使用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' 或文本地址。如果是文本地址,谷歌地图会自行推断纬度

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多