As the title states I want to know how can I find Intersecting point of two different routes in google maps API.
please view this image for better visualisation:
As the title states I want to know how can I find Intersecting point of two different routes in google maps API.
please view this image for better visualisation:
You can use, for example, PolyUtil.isLocationOnPath(LatLng point, java.util.List<LatLng> polyline, boolean geodesic, double tolerance)
from Google Maps Android API Utility Library. In this case you need to iterate over each point of the "red" polyline and check (with isLocationOnPath()
) if it intersects (lays on) each segment of the "blue" polyline. Something like that:
for (LatLng point : redPolyline.getPoints()) {
if (PolyUtil.isLocationOnPath(point, bluePolyline.getPoints(), true, 50)) {
// now "point" - is your target point
pointWhatYouWantToGet = point;
...
}
}
where 50
- is tolerance (in meters).
If you need polylines segments intersection, take a look at this answer of antonio.