自动完成时发生自动完成错误:OVER_QUERY_LIMIT

Ahm*_*sam 7 android google-maps google-places-api google-places

当我尝试在“地点自动完成”中搜索时,出现“无法加载搜索结果” 并且日志显示

“自动填充时出错:OVER_QUERY_LIMIT”

我已启用https://console.cloud.google.com/, 并且API密钥运行良好。

在此处输入图片说明

Java代码

    String apiKey = "MY API KEY";
    private RadioGroup mRadioGroup;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_costumer_map);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);

        Places.initialize(getApplicationContext(), apiKey);

        PlacesClient placesClient = Places.createClient(this);
          // Initialize the AutocompleteSupportFragment.
        AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
                getSupportFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

        // Specify the types of place data to return.
        autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));

        // Set up a PlaceSelectionListener to handle the response.
        autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
            @Override
            public void onPlaceSelected(Place place) {
                destination = place.getName().toString();
                destinationLatLng = place.getLatLng();

                Log.i(TAG, "Place: " + place.getName() + ", " + place.getId());
            }

            @Override
            public void onError(Status status) {
                Log.e(TAG, "onError: " + status);
            }
        });
Run Code Online (Sandbox Code Playgroud)

XML代码

       <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        android:layout_margin="20sp">

        <fragment
            android:id="@+id/place_autocomplete_fragment"
            android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

Vir*_*tel 10

您收到OVER_QUERY_LIMIT消息,因为尚未开发人员控制台中为项目启用计费

要使用Android版Places SDK,您必须在所有API请求中包含一个API密钥,并且必须为每个项目启用计费

检查此链接以获取更多信息和价格。

SKU:基本数据

基本类别中的字段包含在“地方信息”请求的基本费用中,不会产生任何额外费用。当请求以下任何字段时,就会触发基本数据SKU:ADDRESS,ID,LAT_LNG,NAME,OPENING_HOURS,PHOTO_METADATAS,PLUS_CODE,TYPES,USER_RATINGS_TOTAL,VIEWPORT。

您可以在上面提供的相同链接中查看定价和其他SKU 。