tap on map cause an app crash on android
tns info
√ Getting NativeScript components versions information...
√ Component nativescript has 6.7.6 version and is up to date.
√ Component @nativescript/core has 6.5.8 version and is up to date.
√ Component tns-android has 6.5.1 version and is up to date.
√ Component tns-ios has 6.5.1 version and is up to date.
nativescript-mapbox: 5.0.1
if you tap lightly on the over side of the marker (default marker)

error
An uncaught Exception occurred on "main" thread.
Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
StackTrace:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
at com.tns.gen.com.mapbox.mapboxsdk.maps.MapboxMap_OnMapClickListener.onMapClick(MapboxMap_OnMapClickListener.java:19)
at com.mapbox.mapboxsdk.maps.MapGestureDetector.notifyOnMapClickListeners(MapGestureDetector.java:983)
at com.mapbox.mapboxsdk.maps.MapGestureDetector$StandardGestureListener.onSingleTapConfirmed(MapGestureDetector.java:358)
at com.mapbox.android.gestures.StandardGestureDetector$1.onSingleTapConfirmed(StandardGestureDetector.java:81)
at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:323)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Any updates on this issue?
I haven't had a chance to look at it. At my present rate of progress I'll be making another major pass through the plugin in early August.
@wendt88 I figured out the issue. If you uses setOnMapClickListener or setOnMapLongClickListener function you need to return a boolean. The new Mapbox Native SDK allows for multiple listeners on an event and follows the standard pattern of returning 'true' when a handler has handled the event and others shouldn't. Not returning a boolean from the listener function will cause a crash. https://docs.mapbox.com/android/api/map-sdk/9.2.0/index.html
EX:
mapbox.setOnMapClickListener((point: LatLng) => { console.log("Map clicked at latitude: " + point.lat + ", longitude: " + point.lng); // do stuff ... return true });
@TPham92 good find.
@TPham92 thx for your feedback! now i found out, that the app crashs on every map (not marker) tap.
I do not have any listener. debugging a bit I found that on tap it gets called checkForCircleClickEvent as default witch returns false and the app crashs.
@Yermo could you fix this (return true) ASAP please?
@wendt88 I figured out the issue. If you uses setOnMapClickListener or setOnMapLongClickListener function you need to return a boolean. The new Mapbox Native SDK allows for multiple listeners on an event and follows the standard pattern of returning 'true' when a handler has handled the event and others shouldn't. Not returning a boolean from the listener function will cause a crash. https://docs.mapbox.com/android/api/map-sdk/9.2.0/index.html
EX:
mapbox.setOnMapClickListener((point: LatLng) => { console.log("Map clicked at latitude: " + point.lat + ", longitude: " + point.lng); // do stuff ... return true });
Thank you, It's work very fine in my Nativescript-Vue application.
In Vue you need to make a little change in the code, remove the function arrow:
mapbox.setOnMapClickListener(function(point: LatLng) {
console.log("Map clicked at latitude: " + point.lat + ", longitude: " + point.lng);
// do stuff ...
return true
});