Error while updating property 'coordinate' of a view managed by: AIRMapMarker (React native)

前端 未结 5 1160
心在旅途
心在旅途 2021-01-19 18:08

I have been searching the web for proper documentation in regards to this error, am in in no luck as i am unable to determine the cause of this error.

Here is the m

相关标签:
5条回答
  • 2021-01-19 18:13

    I was receiving the lat, lng value as props so what worked for me was:

    <Marker
    coordinate={{
                longitude: longitude ? longitude : 0,
                latitude: latitude ? latitude : 0
              }}
    title={'owner location'}
    />
    
    0 讨论(0)
  • 2021-01-19 18:20

    Changing the initial value in coordinates from null to [] solved the issue.

    <MapView.Polyline
        strokeWidth={2}
        strokeColor="#00ff00"
        coordinates={coords}
    />
    
    0 讨论(0)
  • 2021-01-19 18:23

    Set initial state values to 0 instead of null.

    this.state = {
      latitude:0,
      longitude: 0,
      latitudeDelta: 0.09,
      longitudeDelta: 0.02,
    };

    0 讨论(0)
  • 2021-01-19 18:25

    passing this helped me solve this:

    coordinate={{
         latitude: props && props.position && Number(props.position.latitude) ? Number(props.position.latitude) : 0,
         longitude: props && props.position && Number(props.position.longitude) ? Number(props.position.longitude) : 0 
    }}
    
    0 讨论(0)
  • 2021-01-19 18:32

    The fix is this: while you are updating the <Marker/> component, make sure that you are not passing null in the coordinates' latitude or longitude.

    I faced the same error while looping through an object, where some of my fields were empty. I solved it by defaulting to 0 whenever there was an empty value.

    0 讨论(0)
提交回复
热议问题