3

У меня есть Google Map fragment:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            class="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context="my.package.MapsActivity"
            android:layout_marginTop="?actionBarSize"/>

Мое местоположение получаю вот так:

private void getMyLocation() {
    LatLng latLng = new LatLng(mMap.getMyLocation().getLatitude(), mMap.getMyLocation().getLongitude());
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16);
    mMap.animateCamera(cameraUpdate);
}

Нужно показать маршрут к заданным координатам, как на фото:

2 ответа 2

3

Помогла данная библиотека. Мой код:

Route supportRoute = new Route();

LatLng source = new LatLng(mMap.getMyLocation().getLatitude(), mMap.getMyLocation().getLongitude());
LatLng dest= new LatLng(destLat, destLog);

                supportRoute.drawRoute(mMap, MapsActivity.this, source, dest, true, "en");
1

Как вариант использовать библиотеку Google-Directions-Android

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.