cmdService.execute(commandRequest, new CommandCallback() {
public void onSuccess(CommandResponse response) {
if (response instanceof GetMapConfigurationResponse) {
// Initialize the MapModel and ViewPort:
GetMapConfigurationResponse r = (GetMapConfigurationResponse) response;
// Configure the ViewPort. This will immediately zoom to the initial bounds:
viewPort.setMapSize(display.asWidget().getOffsetWidth(), display.asWidget().getOffsetHeight());
layersModel.initialize(r.getMapInfo(), viewPort, eventBus);
viewPort.initialize(r.getMapInfo(), eventBus);
// Immediately zoom to the initial bounds as configured:
Bbox initialBounds = factory.createBbox(r.getMapInfo().getInitialBounds());
viewPort.applyBounds(initialBounds);
// If there are already some MapGadgets registered, draw them now:
for (Entry<MapGadget, ScreenContainer> entry : gadgets.entrySet()) {
entry.getKey().onDraw(viewPort, entry.getValue());
}
// Initialize the FeatureSelecrtionRenderer:
selectionRenderer.initialize(r.getMapInfo());
addMapGadget(new ScalebarGadget(r.getMapInfo()));
addMapGadget(new WatermarkGadget());
addMapGadget(new NavigationGadget());
// Fire initialization event:
eventBus.fireEvent(new MapInitializationEvent());