【问题标题】:GooglePlacesAutocomplete Basic SearchGooglePlaces自动完成基本搜索
【发布时间】:2020-01-04 18:59:02
【问题描述】:

有没有办法将 GooglePlacesAutocomplete 限制为仅进行基本搜索?我的预感是它要么在query 内,要么我需要删除fetchDetails={true} 并只返回数据......我想这样做,所以我不会收取搜索费用。

    <GooglePlacesAutocomplete
        debounce={200}
        listViewDisplayed="auto"
        minLength={2}
        placeholder="Search..."
        autoFocus={false}
        returnKeyType={'search'}
        fetchDetails={true}
        query={{
            key: API_KEY,
            language: 'en', 
            types: '(cities)' 
        }}
        styles={{
            textInputContainer: {
                backgroundColor: 'rgba(0,0,0,0)',
                borderTopWidth: 0,
                borderBottomWidth:0,
            },
            textInput: {
                marginLeft: 0,
                marginRight: 0,
                height: 38,
                color: '#5d5d5d',
                fontSize: 16
            },
            predefinedPlacesDescription: {
                color: 'black'
            },
        }}
        renderDescription={value => value.description}
        onPress={(data, details) => { 
            updateLocationArray(data, details, timeFrame);
        }}
    /> 

【问题讨论】:

    标签: react-native google-maps google-maps-api-3


    【解决方案1】:

    经过一些研究,我发现您只能使用 google places api 进行搜索。谷歌地图没有免费的搜索版本。希望能帮助到那里的人。

    【讨论】:

      【解决方案2】:

      Google Maps Platform Places API 使用即用即付定价模式,每个请求都会相应地计费。您可以查看更多详情here

      Google Maps Platform 为每个结算帐户提供 200 美元的免费等级信用额度,您可以使用这些信用额度免费请求 API。请注意不要超过此限制,因为一旦此免费信用用完,您将被收取相应的费用。您也可以关注此optimization guide 来帮助您优化使用。

      您还可以使用 Places API 进行各种搜索。您可以有查找地点附近搜索文本搜索请求。在 Google Maps Platform 的documentation 上了解更多信息。

      希望这会有所帮助!

      【讨论】:

        猜你喜欢
        • 2015-01-13
        • 2012-03-20
        • 1970-01-01
        • 1970-01-01
        • 2018-02-05
        • 1970-01-01
        • 2021-12-03
        • 2014-06-15
        相关资源
        最近更新 更多