Android – Google Maps extension – IllegalArgumentException… here is a solution to the problem.
Android – Google Maps extension – IllegalArgumentException
When I call this createMarker() method, I get 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);
}
}
This is logcat output:
06-14 11:40:38.627: I/OGT. RideTracking(25590): Map value is: [email protected]
06-14 11:40:38.627: E/LazyMarker(25590): Options var val: [email protected]
06-14 11:40:38.627: I/LazyMarker(25590): GoogleMap Value:[email protected]
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
My MarkerOptions and GoogleMap values are not empty? The problem is in this line:
marker = map.addMarker(options);
When I comment on the line above, it’s good that the app moves on to the next activity. What is my problem? Any help would be appreciated.
Solution
Caused by: java.lang.IllegalArgumentException: no position in marker options
Obviously, your MarkerOptions
has no place. Call position()
to provide a place to place the marker.