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.