I’m showing a google map with expo in React native (I’m using Expo), but when I try to draw a line with polyline, I get this this error:
Error while updating property ‘lineCap’ of a view managed by: AIRMapPolyline
null
Attempt to invoke virtual method ‘void com.google.android.gms.maps.model…u.g(java.util.List) on a null object reference
This is the code:
<MapView
style={styles.map}
initialRegion={{
latitude: initialLocation.latitude,
longitude: initialLocation.longitude,
latitudeDelta: 0.01,
longitudeDelta: 0.01
}}
>
<Circle
center={currentLocation.coords}
radius={30}
strokeColor='rgba(158, 158, 255, 1.0)'
fillColor='rgba(0, 0, 255, 0.3)'
/>
{drawLine && (
<MapView.Polyline
coordinates={locations.map(loc => {
return {
latitude: loc.coords.latitude,
longitude: loc.coords.longitude
};
})}
strokeColor='red'
strokeWidth={1}
/>
)}
</MapView>
The map draws ok, the circle shows ok, but when I try to draw a line, it throws that awful error.
The array of objects sent as coordinates is ok
The github is GitHub - rafaelsoteldosilva/maptest
You press Start Moving, then press Start Recording, wait a couple of seconds and press Draw, bum!, there’s the error
Rafael