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 โปรดอ่านคีย์ 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
เว้นแต่ว่ากฎหมายที่บังคับใช้หรือตกลงเป็นลายลักษณ์อักษรซอฟต์แวร์ที่แจกจ่ายภายใต้ใบอนุญาตจะถูกแจกจ่ายตาม "ตามพื้นฐาน" โดยไม่มีการรับประกันหรือเงื่อนไขใด ๆ ไม่ว่าจะโดยชัดแจ้งหรือโดยนัย ดูใบอนุญาตสำหรับภาษาเฉพาะที่ควบคุมการอนุญาตและข้อ จำกัด ภายใต้ใบอนุญาต