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
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
}
});