I use the Google Direction API to build a route route between 2 places A and B. I can do this. Now I have a requirement to check if place C falls on the path of route A and B.
Here is a snapshot of the route path that I created from my code.

Here is the relevant code:
function initialize() { var input = document.getElementById('searchTextFieldSource'); var input1 = document.getElementById('searchTextFieldDestination'); var autocomplete = new google.maps.places.Autocomplete(input); var autocomplete1 = new google.maps.places.Autocomplete(input1); google.maps.event.addListener(autocomplete1, 'place_changed', function () { var place = autocomplete.getPlace(); document.getElementById('city1').value = place.name; var place1Lat = place.geometry.location.lat(); var place1Lng = place.geometry.location.lng(); document.getElementById('cityLat1').value = place1Lat; document.getElementById('cityLng1').value = place1Lng; var obj = new Object(); obj.city =place.name; obj.latitude = place.geometry.location.lat(); obj.longitude = place.geometry.location.lng(); locations.push(obj); var place2 = autocomplete1.getPlace(); document.getElementById('city2').value = place2.name; var place2Lat = place2.geometry.location.lat(); var place2Lng = place2.geometry.location.lng(); document.getElementById('cityLat2').value = place2Lat; document.getElementById('cityLng2').value = place2Lng; var obj = new Object(); obj.city = place2.name; obj.latitude = place2.geometry.location.lat(); obj.longitude = place2.geometry.location.lng(); locations.push(obj); directionsDisplay = new google.maps.DirectionsRenderer(); var startPlace = new google.maps.LatLng(place1Lat, place1Lng); var mapOptions = { zoom:7, center: startPlace } var map = new google.maps.Map(document.getElementById('map'), mapOptions); directionsDisplay.setMap(map);
How can i do this?
source share