Reputation: 13316
I just downloaded https://github.com/branflake2267/GWT-Maps-V3-Api
I installed it and copy & pasted some code from their demos. The map is loaded and properly displayed. However, beside this little overview demo there are no further instructions on how to use the MapsWidget... so I (probably) have a simple problem (but I am not able to teach myself how to use the library correctly, due to missing documentation).
This what my code does. I have a list of lat/lon coordinates and I'd like to display a polyline for this path on the map. So, these are the steps my progam has to do:
So, here is my code (which still ignores the waypoints):
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);
}
}
As you can see: This is pretty much the code from the example code. Now in some other widget I do the following:
mapsWidget = new MapsDemoWidget(waypoints);
flex.setWidget(mapWidgetRow, 0, mapsWidget);
If the user selects another route the latter code is called another time. So basically, the first time, the code is executed and the map iss correctly drawn. Then, after having selected another route, this code is again executed. However, after the second time the map remains grey.
The graphic shows the result. As you can see, in the second step, the map is displayed but no card on it. In the second step, the map has been added to the website exactly as the first time.
Upvotes: 1
Views: 305
Reputation: 17489
After adding the MapDemoWidget
call mapWidget.triggerResize();
It should fix the issue.
Upvotes: 2