自动填充时放置自动完成错误:OVER_QUERY_LIMIT

问题描述 投票:0回答:2

当我尝试搜索Place Autocomplete时,我得到了无法加载搜索结果,日志说

“自动完成时出错:OVER_QUERY_LIMIT”

我启用了https://console.cloud.google.com/和API密钥效果很好。

enter image description here

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);
            }
        });

XML code

       <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>
android google-maps google-places-api google-places
2个回答
7
投票

您收到OVER_QUERY_LIMIT消息,因为您尚未在developers console中为您的项目启用结算。

要使用Places SDK for Android,您必须包含所有API请求的API key,并且您必须在每个项目中使用enable billing

查看this link了解更多信息和价格。

SKU:基本数据

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

您可以在上面给出的same link中查看定价和其他SKU。


2
投票

OVER_QUERY_LIMIT表示你超过了你的配额。主要原因是:

如果超出使用限制,您将获得OVER_QUERY_LIMIT状态代码作为响应。

这意味着Web服务将停止提供正常响应并切换到仅返回状态代码OVER_QUERY_LIMIT,直到再次允许更多使用。这可能发生:

  1. 在几秒钟内,如果收到错误,因为您的应用程序每秒发送的请求过多。
  2. 在接下来的24小时内,如果收到错误,因为您的应用程序每天发送的请求过多。每日配额在太平洋时间午夜重置。

您还可以查看此内容以获取更多详细信息:https://developers.google.com/maps/premium/previous-licenses/articles/usage-limits

© www.soinside.com 2019 - 2024. All rights reserved.