【问题标题】:Google Places API Error, but returns successGoogle Places API 错误,但返回成功
【发布时间】:2016-12-22 03:44:37
【问题描述】:

当我注意到某些地址会返回错误而其他地址运行良好时,我正在使用 google places 自动完成 api。然而,即使发生错误,错误回调也会显示错误消息具有error code : 0Success 状态。我正在使用谷歌地方自动完成Fragment

错误打印出来:I/DESTINATION: An error occurred: SUCCESS

private void setDestinationAutocompleteCallbacks() {
    DestinationautocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
      @Override
      public void onPlaceSelected(Place place) {
        LatLng destinationLatLng = place.getLatLng();
        OriginAndDestinationLocations[1] = destinationLatLng;

        mMap.addMarker(new MarkerOptions()
            .position(destinationLatLng)
            .title(getString(R.string.destinationLocation))
            .snippet(place.getAddress().toString()))
            .showInfoWindow();

        if (OriginAndDestinationLocations[0] != null) {
          adjustZoom();
        } else {
          mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(destinationLatLng, Zoom), 2000, null);
        }
      }

      @Override
      public void onError(Status status) {
        Log.i(DESTINATIONTAG, "An error occurred: " + status.getStatusMessage());
      }
    });
}

【问题讨论】:

    标签: android google-maps google-api google-places-api google-places


    【解决方案1】:

    检查您的清单

    <meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_API_KEY"/>
    

    您可以在 android 中为多个应用程序使用相同的 google api 密钥。所以从其他应用程序中删除 google api 密钥。 另一种方法是为当前应用程序生成新的 api 密钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 1970-01-01
      相关资源
      最近更新 更多