简体   繁体   中英

how can i find intersecting point of two routes in google maps api java android?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM