문제

I am using Google Places API and direction API to mark the route between 2 places. I get a polyline for this route. Now I have another polyline which lies on this route.

Eg: Point A to point B -> initial polyline Point C to point D -> second polyline which lies on the A->B polyline.

Using isLocationOnEdge() method, I was able to find out if the C->D polyline lies on the A->B polyline or not.

Problem is I want to find out if the path C->D is in the direction of A->B or reverse. Is there any way to do this?

도움이 되었습니까?

해결책

Using the geometry library, you have a computeHeading method available. Please see the documentation.

You could therefore compute the heading between points A and B and compare it with the heading of points C to D.

var heading = google.maps.geometry.spherical.computeHeading(path.getAt(0), path.getAt(1));

Where path is your first polyline. Then do the same for the second one and compare the results.

Hope this helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top