A preface.

The basic functions that this small demo of Tencent location service product can achieve are as follows: input (positioning) the current position and the destination position, plan the route between two points on the map, and display the distance and toll required by the route, and simulate the vehicle on the route through animation after confirming the journey.

Two. Implementation steps

Realized effect:

Create an Android project and create an Activity. Name it DrivingRouteActivity. First, draw the UI layout. There are two buttons to confirm the route planning, an ImageView to locate the current position, and a TextView to display the route information. The layout code is just for the convenient display of the implementation function, so the layout code is directly posted below:


      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".activity.DrivingRouteActivity">
 
    <com.tencent.tencentmap.mapsdk.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>
 
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="bottom"
        android:paddingTop="10dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <EditText
                android:id="@+id/from_et"
                android:hint="Where do you get on?"
                android:layout_weight="1"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="10dp"
                android:layout_width="match_parent"
                android:layout_height="50dp"></EditText>
            <ImageButton
                android:id="@+id/location_ib"
                android:background="@drawable/sendtocar_balloon"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
                android:layout_marginRight="10dp"
                android:layout_width="50dp"
                android:layout_height="50dp"></ImageButton>
        </LinearLayout>
        <EditText
            android:id="@+id/to_et"
            android:hint="Where are you going?"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"></EditText>
        <TextView
            android:id="@+id/orderdesc_tv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="20sp"></TextView>
        <Button
            android:id="@+id/confirm_btn"
            android:text="Sure"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:visibility="gone"></Button>
        <Button
            android:id="@+id/order_btn"
            android:text="Reservation Express"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"></Button>
    </LinearLayout>
 
</LinearLayout>
Copy the code

1. Account registration and configuration

Before development, we need to register an account on Tencent’s official website for location servicesAfter registration, go to the consoleSelect Key management, click Create new key, and submit the application according to the application information

Configure the applied key under the Application label as follows (replace the value with your own key).

<meta-data
    android:name="TencentMapSDK"
    android:value="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" />
Copy the code

2. Introduce Tencent Android Map SDK

Enter the Android Map SDK and download the 3D map SDK compression packageAfter downloading, open the compressed package, copy the JAR package from the libs folder to the libs directory of the app, right-click the jar package and select Add as library to add it as a dependency, and create a directory named jniLibs under the app\ SRC \main path of the project. Put all packages in the libs/jniLibs/strip folder into the jniLibs directoryAfter import, configure related permissions under the AndroidManifest.xml file

<! -- Access the network for map service -->
<uses-permission android:name="android.permission.INTERNET" />
<! -- Check network availability -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<! -- Access WiFi status -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<! -- Need external storage write permission to save map cache -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<! -- obtain the id of the device -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Copy the code

3. Map initialization

The configuration is complete. Now we start to implement our logic interaction. In order to make the implementation logic clearer, I have divided the business logic code and view rendering code into two packages. And build a DrivingRoutePresent class under the package. DrivingRouteActivity is responsible for view rendering of UI components, and DrivingRoutePresent class is responsible for business logic. Here I also create a contract package and create a DrivingRouteContract interface, which defines the methods between DrivingRoutePresent and DrivingRouteActivity. We define two interfaces in DrivingRouteContract, a View interface for DrivingRouteActivity implementation and a Presenter interface for DrivingRoutePresent implementation, and define some initialization methods

public interface DrivingRouteContract {
    
    interface View{
        void initView(a);// Initialize the View
        void initOnClick(a);// Initialize OnClickListener
        void setOrderDescTV(String content);// Render the order itinerary information
        EditText getFromET(a);
    }
 
    interface Presenter{
        void attachView(DrivingRouteContract.View view);/ / bind the View}}Copy the code

Then let DrivingRouteActivity DrivingRouteContract. View interface initialized and statement in the UI components

public class DrivingRouteActivity extends Activity implements DrivingRouteContract.View.View.OnClickListener {
    private MapView mapView;
    private TencentMap mMap;
    private Button confirmBtn;
    private Button orderBtn;
    private ImageButton locationIB;
    private EditText fromET;
    private EditText toET;
    private TextView orderDescTV;
   private DrivingRoutePresent drivingRoutePresent;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_driving_route);
        initView();
        initOnClick();
    }
 
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.order_btn:
                // Realize itinerary planning
                break;
            case R.id.confirm_btn:
                // Start motion
                break;
            case R.id.location_ib:
                // Locate the current location
                break; }}/** * MapView lifecycle management */
    @Override
    protected void onStart(a) {
        super.onStart();
        mapView.onStart();
    }
 
    @Override
    protected void onResume(a) {
        super.onResume();
        mapView.onResume();
    }
 
    @Override
    protected void onPause(a) {
        super.onPause();
        mapView.onPause();
    }
 
    @Override
    protected void onStop(a) {
        super.onStop();
        mapView.onStop();
    }
 
    @Override
    protected void onDestroy(a) {
        super.onDestroy();
        mapView.onDestroy();
    }
 
    @Override
    protected void onRestart(a) {
        super.onRestart();
        mapView.onRestart();
    }
 
    @Override
    public void initView(a) {
        mapView = findViewById(R.id.mapview);
        confirmBtn = findViewById(R.id.confirm_btn);
        orderBtn = findViewById(R.id.order_btn);
        locationIB = findViewById(R.id.location_ib);
        fromET = findViewById(R.id.from_et);
        toET = findViewById(R.id.to_et);
        orderDescTV = findViewById(R.id.orderdesc_tv);
        mMap = mapView.getMap();
 
        drivingRoutePresent = new DrivingRoutePresent();
        drivingRoutePresent.attachView(this);
    }
 
    @Override
    public void initOnClick(a) {
        orderBtn.setOnClickListener(this);
        confirmBtn.setOnClickListener(this);
        locationIB.setOnClickListener(this);
    }
    
    @Override
    public void setOrderDescTV(String content) {
        orderDescTV.setText(content);
    }
 
    @Override
    public EditText getFromET(a) {
        returnfromET; }}Copy the code

DrivingRoutePresent DrivingRouteContract. Presenter interface

public class DrivingRoutePresent implements DrivingRouteContract.Presenter {
    
    private DrivingRouteContract.View drinvingRouteView;
    
    @Override
    public void attachView(DrivingRouteContract.View view) { drinvingRouteView = view; }}Copy the code

Since we will need to use the context of the current application in several places, we need to write a GlobalApplication context utility class to help us get the context, create a util package, and create a GlobalApplication class for convenience

public class GlobalApplication extends Application {
 
    private static Context context;
 
    @Override
    public void onCreate(a) {
        super.onCreate();
        context = getApplicationContext();
    }
 
    public static Context getContext(a){
        returncontext; }}Copy the code

Also, add the following attribute to the Application tag of the Android class file to load the GlobalApplication above when the application starts

android:name=".util.GlobalApplication"
Copy the code

At this point, we have completed the basic design of the interface and business code, run the app, you can see the basic map information displayed. Next, let’s implement the function of route planning. Tencent’s official Android Map SDK development document has a detailed description of route planning services and address resolution. A sample Demo for invoking is also provided. If you are not sure how to call it, you can refer to the official Demo or the code below.

4. Address resolution and route planning

First we in DrivingRouteContract. The Presenter interface declares a for by address lookup the latitude and longitude geocoder method and a routePlan method for route planning

public interface DrivingRouteContract {
    
    interface View{
        void initView(a);// Initialize the View
        void initOnClick(a);// Initialize OnClickListener
        void setOrderDescTV(String content);// Render the order itinerary information
        EditText getFromET(a);
    }
 
    interface Presenter{
        void attachView(DrivingRouteContract.View view);/ / bind the View
        void geocoder(String address, Integer type);// Address decoding, turn latitude and longitude
        void routePlan(a);// Implement route planning}}Copy the code

By tencent Android SDK map route planning services for the development of the document, we know that to get the planning route need to get starting point and end point of latitude and longitude, and in general business scenario, we will not allow the user to manually enter the latitude and longitude, almost use address resolution services, so I need here by typing Chinese address to obtain the latitude and longitude, Then plan the route by latitude and longitude (but in the actual business is best to add the keyword input prompt service, so that users can find the input location).

Implement both methods in the DrivingRoutePresent class

public static final Integer FROM_TYPE = 0x100; // Get the starting position coordinates
public static final Integer TO_TYPE = 0x101; // Get the destination location coordinates
private LatLng fromLatLng;
private LatLng toLatLng;
 
/** * Address decoding *@paramAddress Passes in the address * to be decoded@paramType Address type, including the start location and destination location */
@Override
public void geocoder(String address, final Integer type) {
    TencentSearch tencentSearch = new TencentSearch(GlobalApplication.getContext());
    Address2GeoParam address2GeoParam =
            new Address2GeoParam(address);
    tencentSearch.address2geo(address2GeoParam, new HttpResponseListener<BaseObject>() {
 
        @Override
        public void onSuccess(int arg0, BaseObject arg1) {
            if (arg1 == null) {
                return;
            }
            Address2GeoResultObject obj = (Address2GeoResultObject)arg1;
            if(obj.result.latLng ! =null) {
                if (type==FROM_TYPE)
                    fromLatLng = obj.result.latLng;
                else if(type==TO_TYPE) toLatLng = obj.result.latLng; routePlan(); }}@Override
        public void onFailure(int arg0, String arg1, Throwable arg2) {
            Log.e("test"."error code:" + arg0 + ", msg:"+ arg1); }}); }private TencentSearch tencentSearch = new TencentSearch(GlobalApplication.getContext());
private StringBuffer lineStringBuilder = new StringBuffer();// Route coordinates
private Double taxiFare = 0d;// Estimate the taxi fare
private Float distance = 0f;// Estimated full distance
 
/** * Route planning */
@Override
public void routePlan(a) {
    if(fromLatLng! =null&&toLatLng! =null){
        Toast.makeText(GlobalApplication.getContext(), "Planning a route for you.", Toast.LENGTH_SHORT).show();
        DrivingParam drivingParam = new DrivingParam(fromLatLng, toLatLng);
        drivingParam.policy(DrivingParam.Policy.TRIP);// Driving route planning strategy, ride-hailing scene, delivering passengers
        drivingParam.setCarNumber("Guangdong A00001");// Fill in the license plate number to avoid the license plate restricted area during route planning
        tencentSearch.getRoutePlan(drivingParam, new HttpResponseListener<DrivingResultObject>() {
 
            @Override
            public void onSuccess(int i, DrivingResultObject drivingResultObject) {
                for (DrivingResultObject.Route route : drivingResultObject.result.routes){
                    for (LatLng latLng : route.polyline){
                        lineStringBuilder.append(latLng.latitude + "," + latLng.longitude);
                        lineStringBuilder.append(",");
                    }
                    distance += route.distance;
                    taxiFare += route.taxi_fare.fare;
                }
                drinvingRouteView.setOrderDescTV("Travel approximately." + distance + "M, is expected to selections" + taxiFare + "Yuan");
 
                // Clear the route, mileage and cost information
                lineStringBuilder = new StringBuffer();
                distance = 0f;
                taxiFare = 0d;
            }
 
            @Override
            public void onFailure(int i, String s, Throwable throwable) {
                Log.d("DrivingRouteActivity"."onSuccess: "+ s + i); }}); fromLatLng=null;
        toLatLng=null; }}Copy the code

The geocoder method is used to obtain the coordinates of the starting position (where to get on the train) and the destination position (where to get off the train). After recording the latitude and longitude of the position, we call the routePlan method to request the route planning interface, and record the mileage and cost information. The latitude and longitude of the points passed during the course of the route (used to realize the car movement behind).

In addition to the common parameters of the route planning interface, there are many other interface parameters. For details, you can view the official interface document and add them as required

Refer to the official interface documentation: lbs.qq.com/AndroidDocs…

5. Vehicle running animation

Once you have the route planning method, add an implementation to the “Reserve express” button

@Override
public void onClick(View view) {
    switch (view.getId()){
        case R.id.order_btn:
            drivingRoutePresent.geocoder(fromET.getText().toString(), DrivingRoutePresent.FROM_TYPE);
            drivingRoutePresent.geocoder(toET.getText().toString(), DrivingRoutePresent.TO_TYPE);
            confirmBtn.setVisibility(View.VISIBLE);
            orderBtn.setVisibility(View.GONE);
            break;
        case R.id.confirm_btn:
            // Start motion
            break;
        case R.id.location_ib:
            // Locate the current location
            break; }}Copy the code

At this point, run the APP, enter the starting point and the end point to get the planned route of driving

Next, we will realize the effect of the car according to the planning route driving function

In DrivingRouteContract. The View in the interface to join the car animation initAnimation initialization method

public interface DrivingRouteContract {
 
    interface Model{}interface View{
        void initView(a);// Initialize the View
        void initOnClick(a);// Initialize OnClickListener
        void setOrderDescTV(String content);// Render the order itinerary information
        EditText getFromET(a);
        void initAnimation(String line);// Initialize the car motion animation
    }
 
    interface Presenter{
        void attachView(DrivingRouteContract.View view);/ / bind the View
        void startLocation(boolean single);
        void stopLocation(a);
        void geocoder(String address, Integer type);// Address decoding, turn latitude and longitude
        void routePlan(a);// Implement route planning}}Copy the code

Implement the initAnimation method, and refer to the above interface document for other parameters of Marker

private Marker mCarMarker;
private LatLng[] mCarLatLngArray;
private MarkerTranslateAnimator mAnimator;
 
@Override
public void initAnimation(String line) {
    // Split to get the latitude and longitude array
    String[] linePointsStr = line.split(",");
    mCarLatLngArray = new LatLng[linePointsStr.length / 2];
    for (int i = 0; i < mCarLatLngArray.length; i++) {
        double latitude = Double.parseDouble(linePointsStr[i * 2]);
        double longitude = Double.parseDouble(linePointsStr[i * 2 + 1]);
        mCarLatLngArray[i] = new LatLng(latitude, longitude);
    }
 
    // Add a car route
    mMap.addPolyline(new PolylineOptions().add(mCarLatLngArray)
        .color(R.color.colorLine));// This color is a custom color in colors.xml
 
    // Add the trolley
    LatLng carLatLng = mCarLatLngArray[0];
    mCarMarker = mMap.addMarker(
            new MarkerOptions(carLatLng)
                    .anchor(0.5 f.0.5 f)
                    .icon(BitmapDescriptorFactory.fromResource(R.mipmap.taxi_t))// Car icon
                    .flat(true)
                    .clockwise(false));
 
    // Create motion animation
    mAnimator = new MarkerTranslateAnimator(mCarMarker, 50 * 1000, mCarLatLngArray, true);
 
    // Adjust the best view
    mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(
            LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50));
}
Copy the code

And call this method in the routePlan method, passing in the route string

// Initialize the car animation
drinvingRouteView.initAnimation(lineStringBuilder.substring(0, lineStringBuilder.length()-1));
Copy the code

Complete code Reference

/** * Route planning */
@Override
public void routePlan(a) {
    if(fromLatLng! =null&&toLatLng! =null){
        Toast.makeText(GlobalApplication.getContext(), "Planning a route for you.", Toast.LENGTH_SHORT).show();
        DrivingParam drivingParam = new DrivingParam(fromLatLng, toLatLng);
        drivingParam.policy(DrivingParam.Policy.TRIP);// Driving route planning strategy, ride-hailing scene, delivering passengers
        drivingParam.setCarNumber("Guangdong A00001");// Fill in the license plate number to avoid the license plate restricted area during route planning
        tencentSearch.getRoutePlan(drivingParam, new HttpResponseListener<DrivingResultObject>() {
 
            @Override
            public void onSuccess(int i, DrivingResultObject drivingResultObject) {
                for (DrivingResultObject.Route route : drivingResultObject.result.routes){
                    for (LatLng latLng : route.polyline){
                        lineStringBuilder.append(latLng.latitude + "," + latLng.longitude);
                        lineStringBuilder.append(",");
                    }
                    distance += route.distance;
                    taxiFare += route.taxi_fare.fare;
                }
                // Initialize the car animation
                drinvingRouteView.initAnimation(lineStringBuilder.substring(0, lineStringBuilder.length()-1));
                drinvingRouteView.setOrderDescTV("Travel approximately." + distance + "M, is expected to selections" + taxiFare + "Yuan");
 
                // Clear the route, mileage and cost information
                lineStringBuilder = new StringBuffer();
                distance = 0f;
                taxiFare = 0d;
            }
 
            @Override
            public void onFailure(int i, String s, Throwable throwable) {
                Log.d("DrivingRouteActivity"."onSuccess: "+ s + i); }}); fromLatLng=null;
        toLatLng=null; }}Copy the code

Finally we start the animation by calling the startAnimation method of the MarkerTranslateAnimator on the click event of the “OK” button

@Override
public void onClick(View view) {
    switch (view.getId()){
        case R.id.order_btn:
            drivingRoutePresent.geocoder(fromET.getText().toString(), DrivingRoutePresent.FROM_TYPE);
            drivingRoutePresent.geocoder(toET.getText().toString(), DrivingRoutePresent.TO_TYPE);
            confirmBtn.setVisibility(View.VISIBLE);
            orderBtn.setVisibility(View.GONE);
            break;
        case R.id.confirm_btn:
            // Start motion
            mAnimator.startAnimation();
            orderBtn.setVisibility(View.VISIBLE);
            confirmBtn.setVisibility(View.GONE);
            break;
        case R.id.location_ib:
            // Locate the current location
            break; }}Copy the code

6. Introduce Tencent Android location SDK

Now that the basic effects are complete, there is one last location feature that needs to be introduced into the Android Location SDK.

We opened the Android Location SDK development documentation and downloaded the latest SDKPut the JAR package in the compressed package under the APP libs package and add it as a dependencyThen copy the so files from the libs folder of the compressed package to the corresponding directory of the jniLibs projectOpen the AndroidManifest.xml file and add the following permission configuration

<! -- Get precise location via GPS -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<! -- Get rough location via network -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<! -- Access the network. Some location information needs to be obtained from the network server -->
<uses-permission android:name="android.permission.INTERNET" />
<! -- Access WiFi status. WiFi information required for network location -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<! -- Modify the WiFi status. Initiate WiFi scan, need WiFi information for network location -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<! Access the network status and check the availability of the network. Network operator information required for network location -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<! -- Changes in access to the network that require certain information for network location -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<! -- To access the current state of the phone, need the device ID for network location -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<! -- Support a-GPS assisted positioning -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<! -- for log -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Copy the code

7. The current location is displayed

After configuration is complete, we in DrivingRouteContract. The Presenter interface to add a start location startLocation and an end to locate stopLocation method

void startLocation(boolean single);
void stopLocation(a);
Copy the code

Let’s implement DrivingRoutePresent again

private boolean IS_SINGLE_LOCATION_MODE = false;// Whether to continuously locate
private TencentLocationManager mLocationManager = TencentLocationManager.getInstance(GlobalApplication.getContext());
private TencentLocationRequest locationRequest;
 
@Override
public void startLocation(boolean single) {
    IS_SINGLE_LOCATION_MODE = single;// Since we only need to position once, we add a parameter
    locationRequest = TencentLocationRequest.create();
    locationRequest.setInterval(5000);// Location interval
    REQUEST_LEVEL_ADMIN_AREA: specifies the latitude and longitude of the location and the administrative region of mainland China
    locationRequest.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA);
    locationRequest.setAllowGPS(true);// Whether to allow GPS positioning
    mLocationManager.requestLocationUpdates(locationRequest, this);// Continuous positioning
}
 
@Override
public void stopLocation(a) {
    mLocationManager.removeUpdates(this);
}
Copy the code

In addition, in order to get the location information of the location, we also need to have DrivingRoutePresent implement the TencentLocationListener interface, Implement onLocationChanged (for receiving location results) and onStatusUpdate (for receiving status codes for GPS,WiFi, and Cell) methods.

@Override
    public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
        if (IS_SINGLE_LOCATION_MODE)
            stopLocation();
        switch (i){
            case TencentLocation.ERROR_OK:
                // The location succeeded
                drinvingRouteView.setLocation(tencentLocation);
                // Render the location information
                if(drinvingRouteView.getFromET()! =null&&drinvingRouteView.getFromET().getText().toString().trim().equals(""))
                    drinvingRouteView.getFromET().setText(tencentLocation.getAddress());
/ / Toast. MakeText (GlobalApplication getContext (), "positioning" success, Toast. LENGTH_SHORT), show ();
                break;
            case TencentLocation.ERROR_NETWORK:
                Toast.makeText(GlobalApplication.getContext(), "Location failure due to network issues.", Toast.LENGTH_SHORT).show();
                break;
            case TencentLocation.ERROR_BAD_JSON:
                Toast.makeText(GlobalApplication.getContext(), "Location failure due to GPS, Wi-Fi, or base station error.", Toast.LENGTH_SHORT).show();
                break;
            case TencentLocation.ERROR_WGS84:
                Toast.makeText(GlobalApplication.getContext(), "Location failed to convert WGS84 to GCJ-02.", Toast.LENGTH_SHORT).show();
                break;
            case TencentLocation.ERROR_UNKNOWN:
                Toast.makeText(GlobalApplication.getContext(), "Location failure due to unknown causes.", Toast.LENGTH_SHORT).show();
                break; }}@Override
    public void onStatusUpdate(String s, int i, String s1) {
        / / TencentLocationListener correction of this method is introduced to GPS, WiFi, Cell status code, specific status code to check the position of the Android SDK documentation development
    }
Copy the code

Finally, we implement the click event bound to the location button. We call the startLocation and stopLocation methods on onResume and onPause to enable the app to automatically locate when it starts or switches back to the current Activity

@Override
public void onClick(View view) {
    switch (view.getId()){
        case R.id.order_btn:
            drivingRoutePresent.geocoder(fromET.getText().toString(), DrivingRoutePresent.FROM_TYPE);
            drivingRoutePresent.geocoder(toET.getText().toString(), DrivingRoutePresent.TO_TYPE);
            confirmBtn.setVisibility(View.VISIBLE);
            orderBtn.setVisibility(View.GONE);
            break;
        case R.id.confirm_btn:
            // Start motion
            mAnimator.startAnimation();
            orderBtn.setVisibility(View.VISIBLE);
            confirmBtn.setVisibility(View.GONE);
            break;
        case R.id.location_ib:
            // Position once
            drivingRoutePresent.startLocation(true);
            break; }}@Override
protected void onResume(a) {
    super.onResume();
    mapView.onResume();
    drivingRoutePresent.startLocation(true);
}
 
@Override
protected void onPause(a) {
    super.onPause();
    mapView.onPause();
    drivingRoutePresent.stopLocation();
}
Copy the code

End three.

Write here, the effect of all the functions on the basic completion, in general, the function is very powerful, for the relevant needs of enterprises to develop up very time and effort. In addition, the development documents and interface documents are more detailed. Due to the limited time, only a few of the services have been experienced temporarily. Students with more needs can explore the official website by themselves.