Google Maps Direção API API para Android
Desde a versão 2.1.2, passará do JCente para o Mavencentral
// build.gradle (project)
allprojects {
repositories {
mavenCentral()
/* ... */
}
}
Gradle
implementation 'com.akexorcist:google-direction-library:1.2.1'
Solicitação de direção simples
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
}
)
Solicitação de direção múltipla de waypoints
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
}
)
ou
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
}
)
Veja o código de exemplo para mais detalhes
Para obter a chave da API, leia a chave da API de direção do Google Maps
Experimente no 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.** { *;}
Veja Changelog.md
Copyright 2021 Akexorcist
Licenciado sob a licença Apache, versão 2.0 (a "licença"); Você não pode usar este trabalho, exceto em conformidade com a licença. Você pode obter uma cópia da licença no arquivo de licença ou em:
http://www.apache.org/license/license-2.0
A menos que exigido pela lei aplicável ou acordada por escrito, o software distribuído pela licença é distribuído "como está", sem garantias ou condições de qualquer tipo, expressa ou implícita. Consulte a licença para o idioma específico que rege as permissões e limitações sob a licença.