Google Maps Direction API Helper для Android
Поскольку версия 2.1.2 перейдет от JCenter в Mavencentral
// build.gradle (project)
allprojects {
repositories {
mavenCentral()
/* ... */
}
}
Градл
implementation 'com.akexorcist:google-direction-library:1.2.1'
Простой запрос на направление
GoogleDirection .withServerKey( " YOUR_SERVER_API_KEY " )
.from( LatLng ( 37.7681994 , - 122.444538 ))
.to( LatLng ( 37.7749003 , - 122.4034934 ))
.avoid( AvoidType . FERRIES )
.avoid( AvoidType . HIGHWAYS )
.execute(
onDirectionSuccess = { direction : Direction ? ->
if (direction.isOK()) {
// Do something
} else {
// Do something
}
},
onDirectionFailure = { t : Throwable ->
// Do something
}
)
Запрос на направление многолетних точек
GoogleDirection .withServerKey( " YOUR_SERVER_API_KEY " )
.from( LatLng ( 41.8838111 , - 87.6657851 ))
. and ( LatLng ( 41.8766061 , - 87.6556908 ))
. and ( LatLng ( 41.8909056 , - 87.6467561 ))
.to( LatLng ( 41.9007082 , - 87.6488802 ))
.transportMode( TransportMode . DRIVING )
.execute(
onDirectionSuccess = { direction : Direction ? ->
if (direction.isOK()) {
// Do something
} else {
// Do something
}
},
onDirectionFailure = { t : Throwable ->
// Do something
}
)
или
val waypoints : List < LatLng > = listOf (
LatLng ( 41.8766061 , - 87.6556908 ),
LatLng ( 41.8909056 , - 87.6467561 )
)
GoogleDirection .withServerKey( " YOUR_SERVER_API_KEY " )
.from( LatLng ( 41.8838111 , - 87.6657851 ))
. and (waypoints)
.to( LatLng ( 41.9007082 , - 87.6488802 ))
.transportMode( TransportMode . DRIVING )
.execute(
onDirectionSuccess = { direction : Direction ? ->
if (direction.isOK()) {
// Do something
} else {
// Do something
}
},
onDirectionFailure = { t : Throwable ->
// Do something
}
)
См. Пример кода для получения более подробной информации
Чтобы получить ключ API, пожалуйста, прочитайте Get Google Maps Direction API -ключ
Попробуйте это в Google Play
-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.* { *; }
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}
-keep class com.akexorcist.googledirection.model.** { *;}
Смотрите Changelog.md
Copyright 2021 Akexorcist
Лицензировано по лицензии Apache, версия 2.0 («Лицензия»); Вы не можете использовать эту работу, кроме как в соответствии с лицензией. Вы можете получить копию лицензии в файле лицензии или по:
http://www.apache.org/licenses/license-2.0
Если это не требуется применимого законодательства или не согласовано в письменной форме, программное обеспечение, распространяемое по лицензии, распределяется по основам «как есть», без каких -либо гарантий или условий, явных или подразумеваемых. См. Лицензию для конкретного языка, регулирующих разрешения и ограничения по лицензии.