首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >not本机-google-places自动完成不使用not本机0.61

not本机-google-places自动完成不使用not本机0.61
EN

Stack Overflow用户
提问于 2020-02-12 11:37:52
回答 3查看 7.1K关注 0票数 2

我已经添加了react本地-谷歌-地点-自动完成与纱线在我的反应-本土cli项目,但它是行不通的。以下是我目前面临的问题。

  1. place下拉列表没有显示在IOS上,但是输入文本字段允许我输入一个地名,但是预测列表没有出现,
  2. onPress处理程序在IOS和ANDROID
  3. 上都没有触发--文本输入来自react-原生的google-place--自动完成功能不允许我在ANDROID上输入任何内容。这就像一直禁用

(尽管焦点设置为true)一样。

注意:启用了所有google位置api,启用了google、places和geocode api,并给出了一个有效的api密钥。

我尝试了所有可能的解决方案,包括:

  1. 设置zIndex: 1000 --为了避免它隐藏在其他视图后面,
  2. 尝试创建新的REACT,只添加了这个组件来保持项目的干净-- API,甚至使用了另一个api,该api与RAP原生版本的早期版本一起工作。

日志在Xcode和Android上都没有显示任何内容。下面是代码片段:

代码语言:javascript
复制
        <View style = {[{zIndex: 2, backgroundColor: 'white'}]}>
                <GooglePlacesAutocomplete
                    ref = {ref => setSearchTextRef(ref)}
                    placeholder='Search for gym'
                    styles={{
                        container: {backgroundColor: 'transparent'},
                        textInputContainer: styles.viewStyle,
                        textInput: styles.textInputStyle,
                    }}
                    keyboardShouldPersistTaps = {'handled'}
                    listUnderlayColor = {'transparent'}
                    textInputProps = {{
                        onFocus: () => focusInput(),
                        onBlur: () => blurInput(),
                        onChangeText: (text) => onChange(text)
                    }}
                    minLength={1} // minimum length of text to search
                    returnKeyType={'search'}
                    listViewDisplayed={'auto'}   // true/false/undefined
                    fetchDetails={true}
                    renderDescription={row => row.description} // custom description render
                    onPress={(data, details = null) => {
                        let coordinates = details.geometry.location;
                        sendCoordinates(coordinates, {data, details});
                    }}
                    getDefaultValue={() => ''}
                    query={{
                        key: googleAPIKey,
                        language: 'en', // language of the results
                        // types: '(cities)' // default: 'geocode'
                    }}
                    nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
                    GooglePlacesSearchQuery={{
                        rankby: 'distance',
                        types: 'gym'
                    }}
                    filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} 
                    debounce={200}
                />
            </View>

提前谢谢你

EN

回答 3

Stack Overflow用户

发布于 2020-04-28 17:37:10

你的代码,加上一些注释,对我有用。注释掉您的函数调用,因为没有提供这些调用。

代码语言:javascript
复制
      <View style = {[{zIndex: 2, backgroundColor: 'white'}]}>
          <GooglePlacesAutocomplete
              //ref = {ref => setSearchTextRef(ref)}
              placeholder='Search for gym'
              styles={{
                  container: {backgroundColor: 'transparent'},
                  //textInputContainer: styles.viewStyle,
                  //textInput: styles.textInputStyle,
              }}
              keyboardShouldPersistTaps = {'handled'}
              listUnderlayColor = {'transparent'}
              textInputProps = {{
                  //onFocus: () => focusInput(),
                  //onBlur: () => blurInput(),
                  //onChangeText: (text) => onChange(text)
              }}
              minLength={1} // minimum length of text to search
              returnKeyType={'search'}
              listViewDisplayed={'auto'}   // true/false/undefined
              fetchDetails={true}
              renderDescription={row => row.description} // custom description render
              onPress={(data, details = null) => {
                  let coordinates = details.geometry.location;
                  console.log(JSON.stringify(details)); //display details in console!
                  //sendCoordinates(coordinates, {data, details});
              }}
              getDefaultValue={() => ''}
              query={{
                key: 'YourKeyHere',
                language: 'en', // language of the results
                  // types: '(cities)' // default: 'geocode'
              }}
              nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
              GooglePlacesSearchQuery={{
                  rankby: 'distance',
                  types: 'gym'
              }}
              filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} 
              debounce={200}
          />
      </View>      
票数 2
EN

Stack Overflow用户

发布于 2022-10-25 06:54:49

这种情况发生在我身上,因为我在ScrollView中有这个控制。在keyboardShouldPersistTaps=上使用ScrollView“handled”似乎可以修复它

票数 0
EN

Stack Overflow用户

发布于 2020-03-06 14:22:22

此软件包不再维护,根本无法工作。我试过在IOS上用博览。我甚至没有得到结果的清单。我发现了另一个像魅力一样有效的包裹:

https://www.npmjs.com/package/react-native-places-input

票数 -6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60187491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档