[英]Calculate the distance between 2 position Google maps Api
We want to create a Line Bus of our City , what kind of Maps Api , we can use , My friend proposed to use Google Map Api.我们要创建一个我们城市的Line Bus,我们可以使用什么样的Maps Api,我的朋友建议使用Google Map Api。 We want to know howto get the distance between 2 places in meter , i found the method distanceFrom() and it generate the distance in the air and not between street .
我们想知道如何以米为单位获得 2 个地方之间的距离,我找到了 distanceFrom() 方法,它生成了空气中的距离,而不是街道之间的距离。 We have a Table of Address , and we want to compare it with a position who came from the user to find the Closest address.
我们有一个地址表,我们想将它与来自用户的位置进行比较以找到最近的地址。 so we need to find the lower distance between the position and all the list of address in the table.
所以我们需要找到位置和表中所有地址列表之间的较低距离。
My code is get distance of 2 point or 2 location in map with google map deriction service我的代码是使用 google map deriction 服务在地图中获得 2 点或 2 个位置的距离
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
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.