I am using angular JS and ng-map. Is it possible to get distance by using map.directionsRenderers[0].directions.routes[0].overview_path
Asked
Active
Viewed 309 times
1 Answers
-1
You can used this code to get your distances.
<p>APPROX DISTANCES: {{map.directionsRenderers[0].directions.routes[0].legs[0].distance.text}}</p>
to know more here is the link: https://developers.google.com/maps/documentation/javascript/examples/directions-simple

Thoudam Albert
- 46
- 7
-
While this code snippet may solve the question, including an explanation [really helps](//meta.stackexchange.com/q/114762) to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Nov 02 '16 at 18:25
-
I got this solution few month back. It was my responsibilities to post it here... But you already have done it ... Thank You Mr. Albert :) Anyway is it possible to calculate map distance without showing the Map ?? – Reedwan Nouman Nov 03 '16 at 03:57
-
yes you can. check in the console.log. here is the code: – Thoudam Albert Nov 03 '16 at 10:22
-
`var directionsService = new google.maps.DirectionsService; var request = { origin: {lat: , lng: },//add latitude and longitude here destination: {lat: , lng: },//add latitude and longitude here travelMode: 'DRIVING' }; directionsService.route(request, function(result, status) { if (status == 'OK') { console.log(result); //you can calculate here } });` – Thoudam Albert Nov 03 '16 at 10:26