GoogleDirectionLibrary
1.1.1
Google地图指示Android的API助手
由于版本2.1.2将从Jcenter转移到Mavencentral
// build.gradle (project)
allprojects {
repositories {
mavenCentral()
/* ... */
}
}
gradle
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密钥,请阅读获取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
版权2021 Akexorcist
根据Apache许可证(版本2.0(“许可”)获得许可;除了符合许可外,您不得使用此工作。您可以在许可证文件中获得许可证的副本,也可以在:
http://www.apache.org/licenses/license-2.0
除非适用法律要求或以书面形式同意,否则根据许可证分配的软件是按照“原样”分发的,没有任何明示或暗示的任何形式的保证或条件。请参阅许可证,以获取执行许可条款和限制的特定语言。