首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angularjs的ng映射中的距离

angularjs的ng映射中的距离
EN

Stack Overflow用户
提问于 2015-11-19 01:34:18
回答 1查看 1.8K关注 0票数 3
代码语言:javascript
复制
<!DOCTYPE html>
 <html>
<head>
<title>Travel modes in directions</title>
 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
 <script src="http://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script>
     <script src="http://code.angularjs.org/1.3.15/angular.js">   </script>
  <script src="http://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<style>
  html, body {width:100%; height: 100%; padding:0; margin: 0}
  body {padding: 5px}
  * { box-sizing: border-box; }
</style>
    </head>
  <body ng-app="ngMap">
       <div style="width: 68%; float:left; height: 100%">
   <div ng-app="" ng-init="loc='current-location'">

   Destination: <input type="text"  ng-model="loc">


   </div>
  <ng-map zoom="14" center="current-location" style="height:90%" >
    <directions
      draggable="true"
      panel="directions-panel"
      travel-mode="DRIVING"
      origin="current-location"
      destination="{{loc}}">
    </directions>
  </ng-map>


  Directions path length:{{map.directionsRenderers[0].directions.routes[0].overview_path.length}}
</div>


<div id="directions-panel" style="width: 28%; float:left; height: 100%; overflow: auto; padding: 0px 5px">
</div>

这是我的代码,用于获取两点之间的行驶方向。用于计算距离的路径长度方向与点之间的实际距离不同。有没有办法可以找到这些点之间的实际距离??请帮助

EN

回答 1

Stack Overflow用户

发布于 2015-11-19 01:47:46

如果要查找两点之间的测地距离,而不是起点和目的地之间沿街道的距离,则应使用google.maps.geometry.spherical名称空间。在角度中,使用google.maps.geometry.spherical.computeDistanceBetween(from:LatLng, to:LatLng, radius?:number)获取距离,或使用google.maps.geometry.spherical.computeLength(path:Array<LatLng>|MVCArray<LatLng>, radius?:number)获取两点之间的测地线长度。

$scope.map只是您设置的作用域对象,实际名称取决于您的设置。

祝好运!

这是resource

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33786642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档