Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

TypeError: undefined is not an object (evaluating 'details.geometry.location')

$
0
0

I'm using react-native-google-places-autocomplete package in my app. There are two fields that uses this package:- Current Location and Destination. Current Location works perfectly fine without error after i entered the location and set the value of lat/lng using details.geometry.location. However, the typeError only occurs after i set the Destination location. Below is my code.

<GooglePlacesAutocomplete         placeholder=""         query={{             key: GOOGLE_PLACES_API_KEY,             language: 'en', // language of the results         }}         onPress={(data, details:any) => { setDestinationLatitude(details.geometry.location.lat.toString()); setDestinationLongitude(details.geometry.location.lng.toString()); }}         onFail={(error) => console.error(error)}         requestUrl={{             url:'https://cors-anywhere.herokuapp.com/https://maps.googleapis.com/maps/api',             useOnPlatform: 'web',}} // this in only required for use on the web. See https://git.io/JflFv more for details.             keyboardShouldPersistTaps='always'             styles={{                  textInputContainer: {                    width: "90%",                    //top: 8,                    alignSelf: 'center'                  },                  textInput: {                    borderColor: grey,                    borderWidth: 1,                    borderRadius: 5,                    height: 48,                    paddingBottom: 8,                    color: black,                    fontSize: 16,                  },                  predefinedPlacesDescription: {                    color: '#1faadb',                  },             }}    />

The following code is exactly what I use for the Current Location field. But why am I getting this typeError when they're exactly the same copy? The only difference are destinationlatitude and destinationlongitude parameters.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>