public void initializeMap ( final MapPresenter mapPresenter , String applicationId , String id , final DefaultMapWidget ... mapWidgets ) { GwtCommand commandRequest = new GwtCommand ( GetMapConfigurationRequest . COMMAND ) ; commandRequest . setCommandRequest ( new GetMapConfigurationRequest ( id , applicationId ) ) ; commandService . execute ( commandRequest , new AbstractCommandCallback < GetMapConfigurationResponse > ( ) { public void execute ( GetMapConfigurationResponse response ) { // Initialize the MapModel and ViewPort: ClientMapInfo mapInfo = response . getMapInfo ( ) ; // Create the map configuration MapConfiguration configuration = createMapConfiguration ( mapInfo , mapPresenter ) ; // We must initialize the map first (without firing the event), as layer constructors may depend on it : ( ( MapPresenterImpl ) mapPresenter ) . initialize ( configuration , false , mapWidgets ) ; // Add all layers: for ( ClientLayerInfo layerInfo : mapInfo . getLayers ( ) ) { ServerLayer < ? > layer = createLayer ( configuration , layerInfo , mapPresenter . getViewPort ( ) , mapPresenter . getEventBus ( ) ) ; mapPresenter . getLayersModel ( ) . addLayer ( layer ) ; } // All layers animated LayersModelRenderer modelRenderer = mapPresenter . getLayersModelRenderer ( ) ; for ( int i = 0 ; i < mapPresenter . getLayersModel ( ) . getLayerCount ( ) ; i ++ ) { modelRenderer . setAnimated ( mapPresenter . getLayersModel ( ) . getLayer ( i ) , true ) ; } // Also add a renderer for feature selection: FeatureSelectionRenderer renderer = new FeatureSelectionRenderer ( mapPresenter ) ; renderer . initialize ( mapInfo ) ; mapPresenter . getEventBus ( ) . addFeatureSelectionHandler ( renderer ) ; mapPresenter . getEventBus ( ) . addLayerVisibilityHandler ( renderer ) ; // now we can fire the initialization event mapPresenter . getEventBus ( ) . fireEvent ( new MapInitializationEvent ( mapPresenter ) ) ; } } ) ; }
Initialize the map by fetching a configuration on the server .