编程语言
首页 > 编程语言> > java – Android – Google Maps Extensions – IllegalArgumentException

java – Android – Google Maps Extensions – IllegalArgumentException

作者:互联网

当我调用这个createMarker()方法时,我得到一个IllegalArgumentException:

private void createMarker(GoogleMap map, MarkerOptions options, OnMarkerCreateListener listener) {
    Log.e("LazyMarker", "Options var val: "+options);
    Log.i("LazyMarker", "GoogleMap Value:"+map);
    Log.i("LazyMarker", "OnMarkerCreateListener Value:"+listener);
    marker = map.addMarker(options);
    //Log.i("LazyMarker", "The value of Marker is:"+map.addMarker(options));
    if (listener != null) {
        listener.onMarkerCreate(this);
    }
}

这是logcat输出:

06-14 11:40:38.627: I/OGT.RideTracking(25590): Map value is: com.google.android.gms.maps.GoogleMap@4249bd30
06-14 11:40:38.627: E/LazyMarker(25590): Options var val: com.google.android.gms.maps.model.MarkerOptions@4318baf8
06-14 11:40:38.627: I/LazyMarker(25590): GoogleMap Value:com.google.android.gms.maps.GoogleMap@4249bd30
06-14 11:40:38.627: I/LazyMarker(25590): OnMarkerCreateListener Value:null
06-14 11:40:38.637: D/AndroidRuntime(25590): Shutting down VM
06-14 11:40:38.637: W/dalvikvm(25590): threadid=1: thread exiting with uncaught exception (group=0x415d7438)
06-14 11:40:38.637: E/AndroidRuntime(25590): FATAL EXCEPTION: main
06-14 11:40:38.637: E/AndroidRuntime(25590): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.gpstracker/com.polaris.epicriders.Rides.RideTracking}: java.lang.IllegalArgumentException: no position in marker options
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2088)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.app.ActivityThread.access$700(ActivityThread.java:139)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.os.Looper.loop(Looper.java:137)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at android.app.ActivityThread.main(ActivityThread.java:4918)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at java.lang.reflect.Method.invokeNative(Native Method)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at java.lang.reflect.Method.invoke(Method.java:511)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
06-14 11:40:38.637: E/AndroidRuntime(25590):    at dalvik.system.NativeStart.main(Native Method)
06-14 11:40:38.637: E/AndroidRuntime(25590): Caused by: java.lang.IllegalArgumentException: no position in marker options

我的MarkerOptions和GoogleMap值不为空?问题在于这一行:

marker = map.addMarker(options);

当我评论上面的线路时,应用程序继续下一个活动就好了.这是我的问题?任何帮助,将不胜感激.

解决方法:

Caused by: java.lang.IllegalArgumentException: no position in marker options

显然,您的MarkerOptions没有位置.请拨打position()以提供放置标记的位置.

标签:android-maps-v2,android,java,google-maps-android-api-2,android-maps-extensions
来源: https://codeday.me/bug/20190825/1721334.html