We want to create a Line Bus of our City , what kind of Maps Api , we can use , My friend prposed to use Google Map Api. We want to know howto get the distance beetwen 2 places in meter , i found the method distanceFrom() and it generate the distance in the air and not beetwen street . We have a Table of Adress , and we want to compare it with a position who came from the user to find the Closest adress. so we need to find the lower distance beetwen the position and all the list of adress in the table. Thank you
1条回答 默认 最新
- duanhuo3392 2014-07-08 17:36关注
My code is get distance of 2 point or 2 location in map with google map deriction service
var PolylineOption = { strokeColor : "blue", strokeOpacity : 0.5, strokeWeight : 5 }; var request = { origin : polyline[0].start, // điểm đầu waypoints : polyline[1].waypoint, destination : polyline[2].end, // Điểm cuối optimizeWaypoints : true, travelMode : google.maps.TravelMode.DRIVING }; rendererOptions = { draggable : true, suppressMarkers : true, polylineOptions : this.PolylineOption }; var Service = new google.maps.DirectionsService(); var Display = new google.maps.DirectionsRenderer(rendererOptions); Display.setMap(map); Service.route(this.request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { distance += response.routes[0].legs[0].distance.value; // distance of 2 location } });
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog