Darius92
Darius92

Reputation: 311

Android: find fastest route between 2 or more points depeding on streets in GoogleMaps

Am adding markers in my app on GoogleMaps,my markers allways are on streets.For example I have moore than 2 markers on map, I need to draw optimal route between them depending on streets.Is there any service to help me, or I need to create my own algorithm? Until now I worked a little with Google Elevation API and Google Direction API, but now I need Google Roads API, to find optimal roads between points? It must be something simmilar to my needs.

Upvotes: 0

Views: 865

Answers (1)

Zahid Rasheed
Zahid Rasheed

Reputation: 1554

Consider using following library: https://github.com/akexorcist/Android-GoogleDirectionLibrary

GoogleDirection.withServerKey("YOUR_SERVER_API_KEY")
        .from(new LatLng(37.7681994, -122.444538))
            .to(new LatLng(37.7749003,-122.4034934))
            .avoid(AvoidType.FERRIES)
            .avoid(AvoidType.HIGHWAYS)
            .execute(new DirectionCallback() {
    @Override
    public void onDirectionSuccess(Direction direction, String rawBody) {
        if(direction.isOK()) {
            // Do something
        } else {
            // Do something
        }
    }

    @Override
    public void onDirectionFailure(Throwable t) {
        // Do something
    }
});

Gradle

compile 'com.akexorcist:googledirectionlibrary:1.0.5'

Upvotes: 2

Related Questions