Code Monkey home page Code Monkey logo

googledirectionlibrary's Introduction

Android Arsenal Maven Central Minimum SDK Version Workflow Status

Android-GoogleDirectionLibrary

Google Direction Library

Google Maps Direction API helper for Android

Google Direction Library

Google Direction Library

Download

Since version 2.1.2 will move from JCenter to MavenCentral

// build.gradle (project)
allprojects {
    repositories {
        mavenCentral()
        /* ... */
    }
}

Gradle

implementation 'com.akexorcist:google-direction-library:1.2.1'

Sample Code

Simple Direction Request

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
            }
        )

Multiple Waypoints Direction Request

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
            }
        )

or

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
            }
        )

See example code for more detail

To get API key, please read Get Google Maps Direction API Key

Demo

Try it at Google Play

ProGuard

-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.** { *;}

Change Log

See CHANGELOG.md

Licence

Copyright 2021 Akexorcist

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

googledirectionlibrary's People

Contributors

akexorcist avatar will1229 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

googledirectionlibrary's Issues

retrofit lib issue

I'm having this problem with your lib dependencies: square/retrofit#854

Can you update your retrofit to retrofit2, I think it will probably fix it:

compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'

Multiple Destination

Hi I saw the image example, there are more than 2 markers. I thought it can be multiple direction.
But when I'm trying Google direction, the builder could not call multiple .to(...).

is it possible to add multiple direction with your API?

Really appreciate for your work.

project not building with firebase

cant build my project if firebase messaging lib is also there in build.gradle with this library

my current setup has play service version 37 and google repository version 38

but it was working with with version 36 but now it is not building

im getting this error

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/actions/ItemListIntents;

and even if i include multidex support i get error

Error:Execution failed for task ':app:transformClassesWithJarMergingForKioskModeUat'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/actions/ItemListIntents.class

build.gradle

.
.
 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('com.mikepenz:materialdrawer:5.6.0@aar') {
        transitive = true
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
    compile 'jp.wasabeef:recyclerview-animators:2.2.4'
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.makeramen:roundedimageview:2.2.0'
    compile 'com.weiwangcn.betterspinner:library:1.1.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.johnkil.android-robototextview:robototextview:2.5.0'
    compile 'com.google.firebase:firebase-messaging:9.6.1'
    compile 'com.akexorcist:googledirectionlibrary:1.0.4'
}
.
.

use custom markers on map

i need to change the markers and use my custom markers... i could not find any provision to change it .... is there any way to so???

problem with dependencies

hi
about one month ago i add this library to my project and it was really good and everything was ok.
but now i don't know what is changed but there are several issues with dependencies (retrofit, okhttp, parceler and etc)
it says failed to resolve those dependencies.
please guide me what i have to do.

thanks for your help

Redraw Polylines

Hi, is there a way to redraw the polylines when the current direction is updated? I am currently removing all the polylines and adding it again but just with a different "from" location. This does not have a good performance, and also consumes a lot of the API. I wish I could only change the "from" location so it doesn't need to redraw all of it. Thanks.

Trust anchor for certification path not found.

Got Exception, Please help me to resolve this issue.

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328)
at okhttp3.internal.io.RealConnection.connectTls(RealConnection.java:195)
at okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:148)
at okhttp3.internal.io.RealConnection.connect(RealConnection.java:111)
at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:188)
at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:127)
at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:289)
at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
at okhttp3.RealCall.getResponse(RealCall.java:240)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:324)
W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:225)
W/System.err: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:115)
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:556)
W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324)
... 17 more
W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
W/System.err: ... 23 more

Multiple dex files define Lcom/google/maps/android/BuildConfig;

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/maps/android/BuildConfig;

This happens when the library google-maps-utils is used.

  implementation project(':google-maps-utils')
    compile 'com.akexorcist:googledirectionlibrary:1.1.1'

Direction not shown

Hello,
First of all thank you for this library.
I'm trying to use it for my application.
The problem is that the "onDirectionSuccess" is called, but nothing is shown on the map.
This is what I wrote :

GoogleDirection.withServerKey("My key obtained in google developper console")
.from(start)
.to(end)
.avoid(AvoidType.FERRIES)
.avoid(AvoidType.HIGHWAYS)
.execute(new DirectionCallback() {
....
}
I put this on a method which takes two parameters LatLng "start" and "end".
Do you know what is the problem?
If needed, I can screen you the whole code or the app.

Thank you.

NPE on DirectionConverter class

Hello bro.
i use you library in my application and my application crashes on your

DirectionConverter

class in method dptopx in line 130 causes NullPointerException
if you like i can help you in this Issue or other Issues
our user have android 5 client

Waypoints

Hi,
your library is very convenient and intuitive to use.
My question is, when are you going to add the waypoint option ?
I'd like very much to use your library in my project, but without this i can't.

com.akexorcist.googledirection.sample E/AndroidRuntime: FATAL EXCEPTION: main

I am using Android Studio and emulator API version 23. I haven't modified application at all and it builds and runs ok, however when I click any of buttons on main screen it crashes.

I have tried adding breakpoints in SimpleDirectionActivity onCreate method, it crashes on setContentView(R.layout.activity_simple_direction); line I have checked and activity_simple_direction.xml is present in layouts.

Full stack trace looks like this:

01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime: FATAL EXCEPTION: main
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime: Process: com.akexorcist.googledirection.sample, PID: 3806
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.akexorcist.googledirection.sample/com.akexorcist.googledirection.sample.AlternativeDirectionActivity}: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class fragment
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #8: Binary XML file line #8: Error inflating class fragment
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.akexorcist.googledirection.sample.AlternativeDirectionActivity.onCreate(AlternativeDirectionActivity.java:37)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:6237)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:256) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.akexorcist.googledirection.sample.AlternativeDirectionActivity.onCreate(AlternativeDirectionActivity.java:37) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:6237) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.io.File.mkdir()' on a null object reference
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.gmm6.m.ad.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.gmm6.c.h.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.gmm6.c.ao.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.e.bd.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.e.ev.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.e.z.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.maps.api.android.lib6.e.y.a(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.maps.internal.u.onTransact(SourceFile:107)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.os.Binder.transact(Binder.java:387)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.dynamic.zza.zza(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1036)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1226)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1328)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2284)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:     at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
01-20 21:19:56.368 3806-3806/com.akexorcist.googledirection.sample E/AndroidRuntime:    at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(Frag
01-20 21:20:00.559 3806-3806/? I/Process: Sending signal. PID: 3806 SIG: 9

Has anyone seen this error before? Why is this failing?

Waypoints

I think you need to add a waypoint to the search path. This can come in handy.

Waypoints

Have you implemented the Waypoints in your library?

Unspecified amount of waypoints

Currently the waypoints seem to be hardcoded into GoogleDirection. Is it possible to implement .and( ) multiple times in something like a for loop? So let's say I have 5 waypoints, it will add 5 waypoints into the map. But another case, I may have 7, how do I handle this?

Leg.getDirectionPoint() returns inconsistent point list

Returned point list from Leg.getDirectionPoint() contains "duplicated" points: point + the same point with higher precision. This results in the Polyline artifacts. See the screenshots:
1
2

I believe this is caused by the method DirectionConverter.convertStepToPosition()

private static void convertStepToPosition(Step step, ArrayList<LatLng> directionPointList) {
    // Get start location
    directionPointList.add(step.getStartLocation().getCoordination()); //point duplication

    // Get encoded points location
    if (step.getPolyline() != null) {
        ArrayList<LatLng> decodedPointList = step.getPolyline().getPointList();
        if (decodedPointList != null && decodedPointList.size() > 0) {
            for (LatLng position : step.getPolyline().getPointList()) {
                directionPointList.add(position);
            }
        }
    }

    // Get end location
    directionPointList.add(step.getEndLocation().getCoordination()); //point duplication
}

Which results in point list that looks like:
lat/lng: (-33.8800144,151.2100253),
lat/lng: (-33.88001,151.21003),
lat/lng: (-33.88019,151.20988),
lat/lng: (-33.8801877,151.2098822),
lat/lng: (-33.8801877,151.2098822),
lat/lng: (-33.88019,151.20988),
...

Code:

    final LatLng origin = new LatLng(-33.88, 151.21);
    final LatLng destination = new LatLng(origin.latitude - 0.01, origin.longitude - 0.01);

    GoogleDirection.withServerKey("")
            .from(origin)
            .to(destination)
            .transportMode(TransportMode.DRIVING)
            .execute(new DirectionCallback() {
                @Override
                public void onDirectionSuccess(Direction direction) {

                    if (direction.isOK()) {
                        googleMap.addMarker(new MarkerOptions().position(origin));
                        googleMap.addMarker(new MarkerOptions().position(destination));

                        ArrayList<LatLng> directionPositionList = direction.getRouteList().get(0).getLegList().get(0).getDirectionPoint();
                        googleMap.addPolyline(DirectionConverter.createPolyline(mapView.getContext(), directionPositionList, 5, Color.RED));
                    } else {

                    }
                }

                @Override
                public void onDirectionFailure(Throwable t) {

                }
            });

Thank you for handy library!

Removing drawn direction from map

Is it possible to remove a (simple) direction after adding it, without calling googleMap.clear(); ? Thanks

if (direction.isOK()){
    Route route = direction.getRouteList().get(0);
    ArrayList<LatLng> directionPositionList = route.getLegList().get(0).getDirectionPoint();
    mPolylineDirections = DirectionConverter.createPolyline(getApplicationContext(), directionPositionList, 5, getResources().getColor(R.color.colorSecondaryDark));
    mGoogleMap.addPolyline(mPolylineDirections);
}

direction.isOK() always return false

` private void makePath() {
GoogleDirection.withServerKey(String.valueOf(R.string.google_direction_api))
.from(origin)
.to(destination)
.execute(new DirectionCallback() {
@OverRide
public void onDirectionSuccess(Direction direction, String rawBody) {
if (direction.isOK()){
try{
List stepList = direction.getRouteList().get(0).getLegList().get(0).getStepList();
ArrayList polylineOptionList = DirectionConverter.createTransitPolyline(MapsActivity.this, stepList, 5, Color.GREEN, 3, Color.BLUE);
for (PolylineOptions polylineOption : polylineOptionList) {
mMap.addPolyline(polylineOption);
}
}catch (Exception e){
e.printStackTrace();
}

                        Toast.makeText(getApplicationContext(), "Route Successfully Displayed", Toast.LENGTH_SHORT).show();
                    }else {
                        Toast.makeText(getApplicationContext(), "Route Not Yet Displayed", Toast.LENGTH_SHORT).show();
                    }
                }

                @Override
                public void onDirectionFailure(Throwable t) {
                    Toast.makeText(getApplicationContext(), "Route Fail Displayed", Toast.LENGTH_SHORT).show();
                }
            });
}`

why direction.isOK() always returning false value ?

error: cannot access AbstractSafeParcelable

I'm getting
Error:(77, 49) error: cannot access AbstractSafeParcelable
class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
when adding Android-GoogleDirectionLibrary dependency.

my com.google.android.gms:play-services-maps and com.google.android.gms:play-services-location are with version 9.8.0

Missing * in ProGuard rules example

In the provided ProGuard rules example there are missing two occurances of * making config to fail on build.

It should look like this:

-keep class com.akexorcist.** { *; }
-keep interface com.akexorcist.* { *; }

-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>;
}

directionPositionList null

Hi, i was using this lib for a few days now and i realized that i can't draw routes anymore, after debugging i noticed that directionPositionList is empty. Any help please

image

ProGuard forgot *

Hello My old brother you forgot * ?
-keep class com.akexorcist.** {* ; }
-keep class com.google.android.gms.maps.** {* ; }

How do I know which marker has been clicked?

First of all, thank you for gorgeous work.

I have a tiny issue. I'm adding many markers on my map. And I want to show route between user's current location and clicked marker location.

GoogleDirection.withServerKey(serverKey)
.from(suanKonumumuz)
.to(?) //What should I write here?
.transportMode(TransportMode.DRIVING)
.execute(this);

Route not getting displayed

I have added the Gradle dependency, and followed the documentation and I can see in the Console that my Google Maps Directions API is being used. But there is no path that is being displayed between the origin and the destination.

If it helps, I am already adding an Origin and a Destination marker to the app, so I hope this library doesn't try to add those markers as well, and might be causing some problem, but still there should've been a visible path.

GoogleDirection.withServerKey("MY_API_KEY")
                        .from(latLngOrigin)
                        .to(latLngDestination)
                        .transportMode(TransportMode.DRIVING)
                        .unit(Unit.IMPERIAL)
                        .avoid(AvoidType.FERRIES)
                        .execute(new DirectionCallback() {
                            @Override
                            public void onDirectionSuccess(Direction direction, String rawBody) {
                                if(direction.isOK()) {
                                    // TODO
                                } else {
                                    // TODO
                                }
                            }

                            @Override
                            public void onDirectionFailure(Throwable t) {
                                // TODO
                            }
                        });

Android 6.0
Android Studio 2.12

Please add error message

I have some issue with my requests because I receive REQUEST_DENIED.
I have no idea why, because API key is correct and service is enabled.

Please add ability to get error message which is contained in error response, like:

{
error_message: "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 109.69.89.52, with empty referer",
routes: [ ],
status: "REQUEST_DENIED"
}

NPE on IsOk method in Direction class

when i build release version of app app gives me this NPE

 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
       at com.akexorcist.googledirection.model.Direction.isOK(Unknown Source)
       at taxi.shiraz.driver.map.MapBuilder$3.onDirectionSuccess(Unknown Source)

REQUEST_DENIED

Hi..keep on getting REQUEST_DENIED yet I have the API key right.
Thanks.

Manifest Merger failed

HI,

I am getting the error
Error:Execution failed for task ':app:processDebugManifest'.
​​

Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 14 declared in library [com.akexorcist:googledirectionlibrary:1.0.4] /Users/agupta/AndroidStudioProjects/DirectionsApp/app/build/intermediates/exploded-aar/com.akexorcist/googledirectionlibrary/1.0.4/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.akexorcist.googledirection" to force usage

I added in the manifest file to override.
Still getting the same error.
Please advise.

Thank You!

Readme

1.1.0 does not work in android studio. 1.0.4 works still

dependencies problem

Hi, i was following your tutorial this and github here. But when i try to run my gradle build have some error

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class

but after i remove the "compile 'com.akexorcist:googledirectionlibrary:1.0.4'" and your code it was back to normal. How should i solve this?

Thank in advance

progurd error

while proguard is true

Process: com.kama.khajoie.sirjan118, PID: 3179
                                                                          java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
                                                                              at com.akexorcist.googledirection.model.Direction.b(Unknown Source)
                                                                              at com.kama.khajoie.sirjan118.Test.a(Unknown Source)
                                                                              at com.akexorcist.googledirection.b.d.a(Unknown Source)
                                                                              at c.u.run(Unknown Source)

signed release app crashes in the direction fragment

after creating a signed apk, when i click the direction button to show the direction in a fragment it shows error like onDirectionSuccess(unknown sources) but in debugging mode it works fine.
please help me....

Why is minimum SDK version 14?

Hi, guys.

Sorry, if I ask improper question, but I really can't understand why the library needs API version 14 or more. Google maps are available from API 11. I changed minimum SDK version to 11, compiled successfully and used to some extend the library. What causes the reason to use higher API?

Regards,
SaQada

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.