首页 > 解决方案 > NativeScript 应用程序在谷歌地图上移动位置时中断

问题描述

我使用 Nativescript 谷歌地图插件在我的移动应用程序中添加了谷歌地图。这是我的html

<MapView #mapView [latitude]="latitude" [longitude]="longitude" [zoom]="zoom" [minZoom]="minZoom" [maxZoom]="maxZoom" [bearing]="bearing" [tilt]="tilt" i-padding="50,50,50,50" [padding]="padding" (mapReady)="onMapReady($event)" (markerInfoWindowTapped)="onMarkerWindowTapped($event)" (cameraChanged)="onCameraChanged($event)" row="1" col="0" colspan="2"> </MapView>

我有一个下拉菜单,其中有一个在地图上显示多个标记的下拉菜单。当我更改下拉列表中的值时,我想更改相机位置。这是我处理下拉更改事件的方式

onchange(args: SelectedIndexChangedEventData) {

let event = this.events.filter(event => event._id === this.itemSource.getValue(args.newIndex));

console.dir(event);
//this.latitude =  event[0].locationInfo.coordinates[0];
//this.longitude = event[0].locationInfo.coordinates[1];

}

如果我取消注释最后 2 行并且相机位置发生更改,此代码将成功执行。但是,更改相机位置后,我遇到了无法调试的未知异常

System.err: java.lang.reflect.InvocationTargetException System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.tns.NativeScriptUncaughtExceptionHandler.uncaughtException(NativeScriptUncaughtExceptionHandler.java:55) System.err: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068) System.err: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063) System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.PendingIntent.send(android.content.Context, int, android.content.Intent)' on a null object reference System.err: at com.tns.ErrorReport.startPendingErrorActivity(ErrorReport.java:156) System.err: at com.tns.ErrorReport.startActivity(ErrorReport.java:133) System.err: ... 4 more System.err: java.lang.reflect.InvocationTargetException System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.tns.NativeScriptUncaughtExceptionHandler.uncaughtException(NativeScriptUncaughtExceptionHandler.java:55) System.err: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068) System.err: at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063) System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.PendingIntent.send(android.content.Context, int, android.content.Intent)' on a null object reference System.err: at com.tns.ErrorReport.startPendingErrorActivity(ErrorReport.java:156) System.err: at com.tns.ErrorReport.startActivity(ErrorReport.java:133) System.err: ... 4 more

有人至少可以提示我可能导致相同的原因吗?请注意,如果我在更改下拉列表时评论更改纬度/经度的行,则一切正常。

标签: androidgoogle-mapstypescriptnativescriptangular2-nativescript

解决方案


推荐阅读