NativeScript / NativeScript/plugins
[@nativescript/google-maps] CameraUpdate.fromCameraPosition causes NullPointerException: CameraPosition must not be null
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 206
- Forks
- 123
- Ø Merge
- 2 T. 1 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei der Android-Implementierung von CameraUpdate.fromCameraPosition und reproduziere den Fehler mit dem TypeScript-Beispiel in diesem Issue. Verfolge die Konvertierung der übergebenen CameraPosition durch die native Bridge; abgeschlossen ist die Aufgabe, wenn ein gültiges CameraUpdate ohne die NullPointerException erstellt wird, auch wenn bearing gesetzt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, typescript
- Bereich
- mobile
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100