NativeScript / NativeScript/plugins
[@nativescript/google-maps] CameraUpdate.fromCameraPosition causes NullPointerException: CameraPosition must not be null
Personne n'a encore pris cette issue.
- Langage dominant
- TypeScript
- Étoiles
- 206
- Forks
- 123
- Merge moyen
- 2 j 1 h
- PR mergées (30 j)
- 1
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’implémentation Android de CameraUpdate.fromCameraPosition et reproduisez l’échec à l’aide de l’exemple TypeScript de cette issue. Suivez la conversion native via le bridge de la CameraPosition fournie ; le travail est terminé lorsqu’un CameraUpdate valide est créé sans la NullPointerException, y compris lorsque bearing est défini.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- android, typescript
- Domaine
- mobile
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100