@Override public void initialize(ClientMapInfo mapInfo, MapEventBus eventBus) { this.mapInfo = mapInfo; this.eventBus = eventBus; crs = mapInfo.getCrs(); // Calculate maximum bounds: maxBounds = new Bbox(mapInfo.getMaxBounds().getX(), mapInfo.getMaxBounds().getY(), mapInfo.getMaxBounds() .getWidth(), mapInfo.getMaxBounds().getHeight()); // if the max bounds was not configured, take the union of initial and layer bounds if (BboxService.equals(maxBounds, Bbox.ALL, 1e-10)) { maxBounds = new Bbox(mapInfo.getInitialBounds().getX(), mapInfo.getInitialBounds().getY(), mapInfo .getInitialBounds().getWidth(), mapInfo.getInitialBounds().getHeight()); if (mapInfo.getLayers() != null && mapInfo.getLayers().size() > 0) { for (ClientLayerInfo layerInfo : mapInfo.getLayers()) { if (layerInfo.getMaxExtent() != null) { maxBounds = BboxService.union(maxBounds, layerInfo.getMaxExtent()); } } } } // Set the best zoom strategy given the map info: if (mapInfo.getScaleConfiguration().getZoomLevels() != null && mapInfo.getScaleConfiguration().getZoomLevels().size() > 0) { zoomStrategy = new FixedStepZoomStrategy(mapInfo, maxBounds); } else { zoomStrategy = new FreeForAllZoomStrategy(mapInfo, maxBounds); } zoomStrategy.setMapSize(mapWidth, mapHeight); initialized = true; }
public void execute(GetMapConfigurationResponse response) { // Initialize the MapModel and ViewPort: ClientMapInfo mapInfo = response.getMapInfo(); ((MapConfigurationImpl) configuration).setServerConfiguration(mapInfo); // Configure the ViewPort. This will immediately zoom to the initial bounds: viewPort.setMapSize(display.getWidth(), display.getHeight()); layersModel.initialize(mapInfo, viewPort, eventBus); viewPort.initialize(mapInfo, eventBus); // Immediately zoom to the initial bounds as configured: viewPort.applyBounds(mapInfo.getInitialBounds()); // Initialize the FeatureSelectionRenderer: selectionRenderer.initialize(mapInfo); // Adding the default map control widgets: if (getWidgetPane() != null) { getWidgetPane().add(new Watermark(MapPresenterImpl.this)); getWidgetPane().add(new Scalebar(MapPresenterImpl.this)); getWidgetPane().add(new ZoomControl(MapPresenterImpl.this), 5, 5); if (!isMobileBrowser) { getWidgetPane().add(new ZoomToRectangleControl(MapPresenterImpl.this), 60, 5); } } // Fire initialization event eventBus.fireEvent(new MapInitializationEvent()); } });