Javascript angularjs的ng映射中的距离 双向行驶模式 html,正文{宽度:100%;高度:100%;填充:0;边距:0} 正文{padding:5px} *{框大小:边框框;} 目的地: 方向路径长度:{{map.directionsrenders[0]。方向.routes[0]。概述{u path.length}

Javascript angularjs的ng映射中的距离 双向行驶模式 html,正文{宽度:100%;高度:100%;填充:0;边距:0} 正文{padding:5px} *{框大小:边框框;} 目的地: 方向路径长度:{{map.directionsrenders[0]。方向.routes[0]。概述{u path.length},javascript,angularjs,ng-map,Javascript,Angularjs,Ng Map,这是我的代码,用于获取两点之间的驾驶方向。用于计算距离的路径长度方向与点之间的实际距离不同。。有没有办法找到点之间的实际距离??Plz帮助如果要查找两点之间的测地距离,而不是起点和终点之间沿街道的距离,则应使用google.maps.geometry.spheremic名称空间。在“角度”中,使用google.maps.geometry.sphereal.ComputedDistanceBeween(from:LatLng,to:LatLng,radius?:number)获取距离或google


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

如果要查找两点之间的测地距离,而不是起点和终点之间沿街道的距离,则应使用
google.maps.geometry.spheremic
名称空间。在“角度”中,使用
google.maps.geometry.sphereal.ComputedDistanceBeween(from:LatLng,to:LatLng,radius?:number)
获取距离或
google.maps.geometry.sphereal.computeLength(路径:数组| MVCArray,radius?:number)
获取两点之间的测地长度

$scope.map
只是您设置的范围对象,实际名称取决于您的设置方式

祝你好运

这是你的电话号码

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