NativeScript / NativeScript/plugins
[@nativescript/google-maps] CameraUpdate.fromCameraPosition causes NullPointerException: CameraPosition must not be null
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 206
- Fork
- 123
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Mô tả
On Android, using GoogleMaps.CameraUpdate.fromCameraPosition() to update the map's camera, especially when including bearing, results in a java.lang.NullPointerException from the native Google Maps SDK.
Steps to Reproduce
-
Set up a blank nativescript-vue project
-
Initialize a nativescript/google-maps MapView.
-
Attempt to create a CameraUpdate using GoogleMaps.CameraUpdate.fromCameraPosition() with a valid CameraPosition object.
import * as GoogleMaps from '@nativescript/google-maps';
// Assume 'map' is an initialized GoogleMaps.GoogleMap instance
// Assume 'map.cameraPosition' has valid data.
// Assume 'newHeading' is a valid number (e.g., from device orientation).
const newCameraPosition: GoogleMaps.CameraPosition = {
target: map.cameraPosition.target,
zoom: map.cameraPosition.zoom,
tilt: map.cameraPosition.tilt,
bearing: newHeading, // Or any valid number, e.g., 20
};
console.log('Input newCameraPosition:', JSON.stringify(newCameraPosition)); // This logs a valid object
try {
const cameraUpdate = GoogleMaps.CameraUpdate.fromCameraPosition(newCameraPosition);
// This line below is never reached
console.log('CameraUpdate created successfully.');
} catch (e: any) {
console.error("Error creating CameraUpdate:", e);
if (global.isAndroid && e.nativeException) {
console.error("Native Android Exception:", e.nativeException);
}
}
Observed Error :
Error creating CameraUpdate fromCameraPosition: Error: java.lang.NullPointerException: cameraPosition must not be null
Native Android Exception during CameraUpdate creation: java.lang.NullPointerException: cameraPosition must not be null
Context & Impact :
-
The newCameraPosition JavaScript object supplied to fromCameraPosition is confirmed to be valid (no null, undefined, or NaN values).
-
This specific NullPointerException indicates an issue in the plugin's native bridge when converting the JavaScript CameraPosition object for fromCameraPosition.
-
As per the plugin's CameraUpdate API, fromCameraPosition is the only method that allows for setting the bearing alongside other camera parameters.
-
This bug currently prevents any programmatic control over the map's bearing, which is critical for features like compass-oriented maps.
Environment
- nativescript-vue: "3.0.1"
- @nativescript/google-maps : "1.8.0"
- Platform: Android
- Device Model: emulated Pixel 4 but also on hardware
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ phần triển khai Android của CameraUpdate.fromCameraPosition và tái hiện lỗi bằng ví dụ TypeScript trong issue này. Theo dõi quá trình chuyển đổi CameraPosition được cung cấp qua native bridge; hoàn thành khi tạo được một CameraUpdate hợp lệ mà không xảy ra NullPointerException, kể cả khi bearing được thiết lập.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, typescript
- Lĩnh vực
- mobile
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100