我正在尝试开发一个android应用程序。我正在使用direction API
在两个route
之间绘制marker
。我正在使用以下代码绘制route
。当我第一次运行应用程序时,它运行良好。但第二次direction api
显示OVER_QUERY_LIMIT
。
GoogleDirection.withServerKey("AIzaSyCua7p46J7YKwxS99H5orm2Ikn8OltIcF0")
.from(currentLatLng)
.to(desLatLng)
.transportMode(TransportMode.DRIVING)
.execute(this);
@Override
public void onDirectionSuccess(Direction direction, String rawBody) {
Toast.makeText(getApplicationContext(),"Success with status : " +direction.getStatus(),Toast.LENGTH_LONG).show();
if (direction.isOK()) {
Route route = direction.getRouteList().get(0);
int legCount = route.getLegList().size();
for (int index = 0; index < legCount; index++) {
Leg leg = route.getLegList().get(index);
//mMap.addMarker(new MarkerOptions().position(leg.getStartLocation().getCoordination()));
if (index == legCount - 1) {
// mMap.addMarker(new MarkerOptions().position(leg.getEndLocation().getCoordination()));
}
List<Step> stepList = leg.getStepList();
ArrayList<PolylineOptions> polylineOptionList = DirectionConverter.createTransitPolyline(this, stepList,
5, Color.BLACK, 3, Color.BLUE);
for (PolylineOptions polylineOption : polylineOptionList) {
mMap.addPolyline(polylineOption);
}
}
setCameraWithCoordinationBounds(route);
} else {
Toast.makeText(getApplicationContext(),direction.getStatus(),Toast.LENGTH_LONG).show();
}
}
@Override
public void onDirectionFailure(Throwable t) {
Toast.makeText(getApplicationContext(),t.getMessage(),Toast.LENGTH_LONG).show();
}
答案 0 :(得分:1)
由于没有结算帐户,您可能会看到“ OVER_QUERY_LIMIT”,要使用Google Direction API,您必须在开发者控制台中设置结算帐户。