Java Google Map Directions.load失败,返回服务器错误

Java Google Map Directions.load失败,返回服务器错误,java,google-maps,gwt,jakarta-ee,Java,Google Maps,Gwt,Jakarta Ee,我正在试用gwt地图库中的谷歌方向。 除了在onModuleLoad()中分配RootPanel外,我还复制了SimpleDirectionsDemo.java中的大部分代码 运行后,我收到一个“加载方向失败:服务器出错”的消息回调 Directions.load(query, opts, new DirectionsCallback() { public void onFailure(int statusCode) { Window.alert("Failed to load d

我正在试用gwt地图库中的谷歌方向。 除了在onModuleLoad()中分配RootPanel外,我还复制了SimpleDirectionsDemo.java中的大部分代码

运行后,我收到一个“加载方向失败:服务器出错”的消息回调

Directions.load(query, opts, new DirectionsCallback() {

  public void onFailure(int statusCode) {
    Window.alert("Failed to load directions: Status "
        + StatusCodes.getName(statusCode) + " " + statusCode);
  }

  public void onSuccess(DirectionResults result) {
    GWT.log("Successfully loaded directions.", null);
  }
});

  • GWT地图库的API:

  • 工作示例可在以下位置找到:

  • 而文件可在

下面是在主干中找到的工作代码片段


任何有谷歌地图或gwt地图经验的人都知道为什么加载失败

我意识到这一点,决定省去方向面板

我最初的DirectionQueryOptions代码是

DirectionQueryOptions opts = new DirectionQueryOptions(map);
这显然会导致服务器错误 基于

api有一个错误,因为它提供了一个构造函数,其中只有map作为参数。 如果要使用gwt映射库,则必须声明DirectionsPanel

正确代码:

DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);
DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);