bramus / react-native-maps-directions

Directions Component for `react-native-maps`
MIT License
1.25k stars 197 forks source link

Cannot read property 'map' of undefined #130

Closed carlossuds closed 4 years ago

carlossuds commented 4 years ago

When I take out the origin property of the Directions component, it runs with no errors but doesn't show the direction. When I put it, for obvious reasons, I get this error.

return (
    <View style={{flex: 1}}>
      <MapView
        style={{flex: 1}}
        region={region}
        showsUserLocation
        loadingEnabled>
        <MapView.Marker coordinate={region} />
        <MapView.Marker
          coordinate={{latitude: -9.645601, longitude: -35.734108}}
        />
        <MapViewDirections
          origin={{latitude: -9.64561693, longitude: -35.73592044}}
          destination={{latitude: -9.645601, longitude: -35.734108}}
          apikey={'AIzaSyBVFhY3cURPTbAoOnkyAeijkAt2kqRJ2iY'}
          strokeWidth={3}
          strokeColor="#333"
        />
      </MapView>
    </View>
  );
}
jdbaculard commented 4 years ago

same

Capture d’écran 2020-03-14 à 10 26 56
ArbazYousuf commented 4 years ago

@carlossuds @jdbaculard you have used version 1.7.3 or less but this package update recently just simply do one thing go to package.json and change "react-native-maps-directions": "^1.7.3", to "react-native-maps-directions": "1.7.3", after this run npm install or yarn install just stick on the version your already use do not change if it is not necessary

carlossuds commented 4 years ago

@carlossuds @jdbaculard you have used version 1.7.3 or less but this package update recently just simply do one thing go to package.json and change "react-native-maps-directions": "^1.7.3", to "react-native-maps-directions": "1.7.3", after this run npm install or yarn install just stick on the version your already use do not change if it is not necessary

Thank you @ArbazYousuf , it worked perfectly! :)

ramonhoyo commented 4 years ago

Hi, I'm facing the same problem. my dependencies are:

"react-native-maps": "^0.27.0",
"react-native-maps-directions": "1.7.3", << As you seggested before. don't work for me. 
ArbazYousuf commented 4 years ago

@ramonhoyo show me your source code

jdbaculard commented 4 years ago
"react-native-maps": "0.26.1",
"react-native-maps-directions": "^1.7.0",

it works for me now ! Thanks

chamodKanishka commented 4 years ago

"react-native-maps": "^0.27.0" "react-native-maps-directions": "^1.7.4"

but still i have this problem

ArbazYousuf commented 4 years ago

"react-native-maps": "^0.27.0" "react-native-maps-directions": "^1.7.4"

but still i have this problem

send the waypoint like an array of object

<MapViewDirections waypoint={[ {...} ]} ... />

ramonhoyo commented 4 years ago

@ramonhoyo show me your source code

Hi @ArbazYousuf , I'm running the most basic example as described here, my code looks like:

    <MapViewDirections
      origin={origin}
      destination={destination}
      apikey={GOOGLE_MAPS_APIKEY}
    />

I've tried @jdbaculard setup, but when I do that I get the following error:

FAILURE: Build failed with an exception.

bramus commented 4 years ago

Version 1.7.5 with a fix for this got released. Thanks for the input, everyone!

Rafazor commented 4 years ago

I still have this problem

bramus commented 4 years ago

@Rafazor Which version of react-native-maps-directions are you running? If you already are running version 1.7.5 then please provide a minimal demo to reproduce the error you are seeing.

Rafazor commented 4 years ago

I'm running 1.7.5, but after a full clean of the project the"Cannot read property 'map' of undefined" is gone and now I have this error.

console.error: "Unhandled promise rejection", TypeError: Cannot read property 'distance' of undefined

module.exports host-report-errors.js:6:56 dispatchEvent es.promise.js:147:41 perform$argument_0 es.promise.js:159:15 module.exports perform.js:3:34 task.call$argument_1 es.promise.js:156:15

..................................................

"react-native-maps": "0.26.1",
"react-native-maps-directions": "^1.7.5",
bramus commented 4 years ago

@Rafazor Please refer to https://github.com/bramus/react-native-maps-directions/issues/132#issuecomment-600057488 regarding this, as it was already mentioned there. If you could try and verify the suggested solution, I'll publish a new version with the fix.

umutlaguler commented 3 years ago

@carlossuds @jdbaculard you have used version 1.7.3 or less but this package update recently just simply do one thing go to package.json and change "react-native-maps-directions": "^1.7.3", to "react-native-maps-directions": "1.7.3", after this run npm install or yarn install just stick on the version your already use do not change if it is not necessary

thanks it worked well