I'm trying out google directions from the gwt-map library. Apart from assigning RootPanel in onModuleLoad(), I have copied most of the codes from SimpleDirectionsDemo.java.
我正在尝试从gwt-map库中获取google指令。除了在onModuleLoad()中分配RootPanel之外,我还复制了SimpleDirectionsDemo.java中的大部分代码。
I get a "Failed to load directions: SERVER_ERROR" message callback after running
运行后,我收到“无法加载路线:SERVER_ERROR”消息回调
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);
}
});
-
API of GWT-Map Library: http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/index.html
GWT-Map Library的API:http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/index.html
-
The working example can be found at http://gwt.google.com/samples/hellomaps-1.1.0/HelloMaps.html#Simple%20Directions
可以在http://gwt.google.com/samples/hellomaps-1.1.0/HelloMaps.html#Simple%20Directions找到该工作示例
-
while the files can be found at
http://code.google.com/p/gwt-google-apis/source/browse/#svn%2Ftrunk%2Fmaps%2Fsamples%2Fhellomaps%2Fsrc%2Fcom%2Fgoogle%2Fgwt%2Fmaps%2Fsample%2Fhellomaps%2Fclient%253Fstate%253Dclosed文件可以在http://code.google.com/p/gwt-google-apis/source/browse/#svn%2Ftrunk%2Fmaps%2Fsamples%2Fhellomaps%2Fsrc%2Fcom%2Fgoogle%2Fgwt%2Fmaps%找到2Fsample%2Fhellomaps%2Fclient%253Fstate%253Dclosed
and here's a snippet of the working code thats found in the trunk..
这是一个在主干中找到的工作代码的片段..
public SimpleDirectionsDemo() {
final Grid grid = new Grid(1, 2);
grid.setWidth("100%");
grid.getCellFormatter().setWidth(0, 0, "500px");
grid.getCellFormatter().setVerticalAlignment(0, 0,
HasVerticalAlignment.ALIGN_TOP);
grid.getCellFormatter().setWidth(0, 1, "300px");
grid.getCellFormatter().setVerticalAlignment(0, 1,
HasVerticalAlignment.ALIGN_TOP);
map = new MapWidget(LatLng.newInstance(42.351505, -71.094455), 15);
map.setHeight("480px");
grid.setWidget(0, 0, map);
DirectionsPanel directionsPanel = new DirectionsPanel();
grid.setWidget(0, 1, directionsPanel);
directionsPanel.setSize("100%", "100%");
initWidget(grid);
DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);
String query = "from: 500 Memorial Dr, Cambridge, MA to: 4 Yawkey Way, Boston, MA";
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);
}
});
}
Anyone experienced with either google maps or gwt-map knows why does the load fail ?
任何有谷歌地图或gwt-map经验的人都知道为什么负载会失败?
1 个解决方案
#1
0
Realized on my end, I decided to leave out the DirectionsPanel.
在我结束时意识到,我决定省略DirectionsPanel。
My original code for DirectionQueryOptions was
我对DirectionQueryOptions的原始代码是
DirectionQueryOptions opts = new DirectionQueryOptions(map);
which apparently causes SERVER_ERROR Based on the API at http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/index.html
显然导致SERVER_ERROR基于http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/index.html上的API
There's an error with the api since it gives a constructor with just map as a parameter. DirectionsPanel is mandatory to be declared if you're going to use gwt-map library
api有一个错误,因为它给构造函数只有map作为参数。如果您要使用gwt-map库,则必须声明DirectionsPanel
Correct code:
DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);
#1
0
Realized on my end, I decided to leave out the DirectionsPanel.
在我结束时意识到,我决定省略DirectionsPanel。
My original code for DirectionQueryOptions was
我对DirectionQueryOptions的原始代码是
DirectionQueryOptions opts = new DirectionQueryOptions(map);
which apparently causes SERVER_ERROR Based on the API at http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/index.html
显然导致SERVER_ERROR基于http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/index.html上的API
There's an error with the api since it gives a constructor with just map as a parameter. DirectionsPanel is mandatory to be declared if you're going to use gwt-map library
api有一个错误,因为它给构造函数只有map作为参数。如果您要使用gwt-map库,则必须声明DirectionsPanel
Correct code:
DirectionQueryOptions opts = new DirectionQueryOptions(map, directionsPanel);