Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference getDouble
Asked Answered
R

0

5

I am using react-native-maps library to show google maps in react-native application. I am tracking user movement and want to rotate the map when location will be changed. For map rotation I am calculating rotation angle and using animateCamera trying to rotate the map like the following:

this.map.animateCamera({
    heading: rotation,
    center: {latitude: currentLocation.latitude, longitude: currentLocation.longitude},
    pitch: this.state.currentAngle
}, {duration: 1000});

I've checked and rotation, latitude, longitude, currentAngle are not null or empty objects

But this method throws an error like this: enter image description here

After this, I tried to use animateToBearing method, which is deprecated, as documentation says, but works nicely and rotates the map but shows the deperecation warning.

Versions:
    expo: 32.0.0,
    expo-cli: 2.2.0,
    react-native-maps: 0.23.0

Any solutions?

P.S. I've searched similar questions on github.com and stackoverflow.com and this question is not duplicated

Recount answered 23/3, 2019 at 19:14 Comment(3)
It’s probably due to your current location being null at some point.Outcry
no, I checked latitude and longitude values, they are initializedRecount
I had similar issue with Unity. I added ndk { abiFilters 'armeabi-v7a' } to app/build.gradle under defaultConfig properties. Try it. EDIT: I don't use Expo and I don't know how android code is executed with Expo.Sweet

© 2022 - 2024 — McMap. All rights reserved.