react-native-google-places-autocomplete icon indicating copy to clipboard operation
react-native-google-places-autocomplete copied to clipboard

Continuously searching location and onPress not working

Open MaheshRupnavar opened this issue 1 year ago • 9 comments

When I enter a location on Google places it searches continuously and also onPress is not working. In the latest version I used, So because of continuously hitting Google api key, google console gives me 2000 $ bill. Fix the latest version issue. Please help me to solve issue

here is my code

              <GooglePlacesAutocomplete
                    ref={googlePlacesRef}
                    styles={{
                        textInput: { color: COLORS.black, fontFamily: FONTS.medium },
                        textInputContainer: {
                            backgroundColor: COLORS.white,
                            color: COLORS.black,
                            borderRadius: 10,
                            shadowColor: COLORS.black,
                            shadowOpacity: 0,
                            elevation: 5,
                            shadowOffset: { height: 3, width: 0 },
                            shadowRadius: 4,
                        },
                        container: {
                            backgroundColor: COLORS.white,
                            borderWidth: 1,
                            marginLeft: 4,
                            marginRight: 4,
                            borderRadius: 5,
                            borderColor: COLORS.lightGrey
                        },
                        row: {
                            backgroundColor: COLORS.white,
                            padding: 13,
                            height: 44,
                            flexDirection: 'row',
                        },
                    }}
                    renderRow={(rowData) => {
                        const title = rowData.structured_formatting.main_text;
                        const address = rowData.structured_formatting.secondary_text;
                        return (
                            <View>
                                <Text style={{ fontSize: 14, color: COLORS.black, fontFamily: FONTS.regular }}>{title}, {address}</Text>
                            </View>
                        );
                    }}
                    textInputProps={{
                        placeholderTextColor: COLORS.lightGrey
                    }}
                    placeholder='Search For Your Location'

                    onPress={(data, details = null) => {
                        console.log('----data-----', data, details)
                        // setAddress(data.description);
                        AddressToCoordinates(data.description);
                        // AddressToCoordinates(data,details);
                    }}
          
                    renderRightButton={() => {
                        return (
                            <>
                                {
                                    address ? (
                                        <TouchableOpacity
                                            onPress={clearAddressInput} // Clear the address when cross icon is pressed
                                            style={{ justifyContent: 'center', marginRight: 10 }}
                                        >
                                            <Ionicons name='close-circle' size={24} color="gray" />
                                        </TouchableOpacity>
                                    ) :
                                        null
                                }
                            </>
                        )
                    }}

                    query={{
                        key: GOOGLE_KEY,
                        language: 'en',
                    }}
                />

MaheshRupnavar avatar Sep 19 '24 07:09 MaheshRupnavar