Location:

Automobile Routing

Design a travel plan tailored to the user based on the departure location, destination, and set path strategy. At the same time, combined with real-time traffic, it helps users to bypass congested sections and provide a more intimate and more user-friendly driving route. The sample code is as follows:

                // Set the starting point and end point coordinates
                GeoPoint startGeoPoint = new GeoPoint(116.39750, 39.90850); //Tiananmen
                GeoPoint endGeoPoint = new GeoPoint(116.43423, 39.93766); //Dongzhimen Street
                RoutePlan routePlan = new RoutePlan();
                // Set the listener
                routePlan.setListener(new RoutePlan.Listener() {
                    @Override
                    public void onSuccess(final RouteResult result) {
                        //search successful
                    }
        
                    @Override
                    public void onFail(final APIStatus status) {
                        //Query failed
                    }
                });
                // Set the request parameters
                RoutePlan.Query query = RoutePlan.Query.newQuery(startGeoPoint, endGeoPoint, RoutePlanType.CAR);
                // Set the route mode
                query.setPolicy(0);
                // Set to return a route, the value range is 1 <= num <= 3;
                query.setNum(1);
                routePlan.setQuery(query);
                //Initiate a request
                routePlan.plan();
            

RoutePlan.Query Description:
1. Obtain an instance by using the newQuery (GeoPoint startPoint, GeoPoint endPoint, int queryType) method in RoutePlan.Query; 2. startPoint starting point GeoPoint coordinates;
3. endPoint endpoint GeoPoint coordinates;
4. queryType calculation type, driving calculation type is RoutePlanType.CAR;
5. setNum(int num) sets the number of rows returned by the algorithm, num takes the range 1 <= num <= 3;
6. The setPolicy(int policy) method is used to set the conditions for the calculation. The value of the policy is as follows:

valuemeaning

0

Default (road condition + time + mileage comprehensive consideration)

1

Dodge congestion

2

Do not take high speed

3

High Speed ​​Priority

4

Avoid Charge

5

Dod to avoid congestion & not to go high speed

6

Dodge congestion & high speed priority

7

Dodge congestion & avoid charges

8

Dod to avoid congestion & avoid high speed & avoid charges

0

Do not go high speed & avoid charges

Note: The result return interface is an asynchronous thread interface. If the Android project needs to operate the control in the return, it must switch to the Main main thread.

TOP