NativeScript / NativeScript/plugins
[@nativescript/google-maps] CameraUpdate.fromCameraPosition causes NullPointerException: CameraPosition must not be null
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 206
- フォーク
- 123
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 1
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
CameraUpdate.fromCameraPosition の Android 実装から始め、この issue の TypeScript 例を使って失敗を再現してください。渡された CameraPosition の native bridge での変換を追跡してください。bearing が設定されている場合も含め、NullPointerException なしで有効な CameraUpdate が作成されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- android, typescript
- 領域
- mobile
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100