使用GWT Maps v3更新地图时出现问题
我刚下载了 我安装了它,并从他们的演示中复制粘贴了一些代码。地图已加载并正确显示。然而,除了这个小的概述演示之外,没有关于如何使用MapsWidget的进一步说明。。。因此,我(可能)有一个简单的问题(但由于缺少文档,我无法自学如何正确使用库) 这就是我的代码所做的。我有一个lat/lon坐标列表,我想在地图上显示该路径的多段线。因此,我的程序必须执行以下步骤:使用GWT Maps v3更新地图时出现问题,gwt,google-maps-api-3,Gwt,Google Maps Api 3,我刚下载了 我安装了它,并从他们的演示中复制粘贴了一些代码。地图已加载并正确显示。然而,除了这个小的概述演示之外,没有关于如何使用MapsWidget的进一步说明。。。因此,我(可能)有一个简单的问题(但由于缺少文档,我无法自学如何正确使用库) 这就是我的代码所做的。我有一个lat/lon坐标列表,我想在地图上显示该路径的多段线。因此,我的程序必须执行以下步骤: 初始化MapWidget并显示地图(works) 如果选择了新路由(不工作),则更新MapWidget 下面是我的代码(它仍然忽略了航
添加
MapDemoWidget
调用mapWidget.triggerResize()代码>
它应该解决这个问题
public class MapsDemoWidget extends SimplePanel {
private static MapWidget mapWidget;
ArrayList<WayPoint> waypoints;
public MapsDemoWidget(ArrayList<WayPoint> waypoints) {
this.waypoints = waypoints;
loadMapApi();
}
private void loadMapApi() {
boolean sensor = true;
// load all the libs for use in the maps
ArrayList<LoadLibrary> loadLibraries = new ArrayList<LoadApi.LoadLibrary>();
loadLibraries.add(LoadLibrary.DRAWING);
loadLibraries.add(LoadLibrary.GEOMETRY);
loadLibraries.add(LoadLibrary.VISUALIZATION);
Runnable onLoad = new Runnable() {
@Override
public void run() {
drawMap();
}
};
LoadApi.go(onLoad, loadLibraries, sensor);
}
private void drawMap() {
LatLng centerCoords = LatLng.newInstance(52.499095d,13.406220d);
MapOptions opts = MapOptions.newInstance();
opts.setZoom(14);
opts.setCenter(centerCoords);
opts.setMapTypeId(MapTypeId.ROADMAP);
mapWidget = new MapWidget(opts);
mapWidget.setSize("750px", "500px");
this.add(mapWidget);
}
}
mapsWidget = new MapsDemoWidget(waypoints);
flex.setWidget(mapWidgetRow, 0, mapsWidget);