我使用Google Places API添加地点。以下是GoogleApiClient和添加地点的代码。
开始缩进代码:
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.enableAutoManage(this, 0, this)
.addApi(Places.GEO_DATA_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mGoogleApiClient.connect();
AddPlaceRequest place =
new AddPlaceRequest(
"xyz",
new LatLng(point.latitude, point.longitude),
"2095",
Collections.singletonList(Place.TYPE_SHOE_STORE),
"+123456789",
Uri.parse("www.abc.com/")
);
Places.GeoDataApi.addPlace(mGoogleApiClient, place).setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
Log.e(TAG, "Place query did not complete. Error: " + places.getStatus().toString());
places.release();
return;
}
final Place place = places.get(0);
Log.i(TAG, "Place add result: " + place.getName());
places.release();
}
});
我的输出为:
地方查询未完成。错误:
状态{statusCode = PLACES_API_USAGE_LIMIT_EXCEEDED,resolution = null}
我甚至没有为Google Places API请求超过25次。即使我尝试从不同的帐户,它也给了我同样的错误。提前谢谢。