public void onActivate(MapPresenter mapPresenter) { super.onActivate(mapPresenter); idleController.onActivate(mapPresenter); insertController.setMaxBounds(mapPresenter.getConfiguration().getServerConfiguration().getMaxBounds()); dragController.setMaxBounds(mapPresenter.getConfiguration().getServerConfiguration().getMaxBounds()); }
@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; }
/** * Calculate max bounds based on the map's max bounds, combined with the layer's bounds. * @return Polygon based on the max bounds bbox. */ private Geometry getMaxBoundsAsGeometry() { ClientMapInfo mapModel = territoryMap.getMapModel().getMapInfo(); Bbox result = mapModel.getMaxBounds(); for (ClientLayerInfo layer : mapModel.getLayers()) { result = BboxService.union(result, layer.getMaxExtent()); } if (result == null || result.getHeight() == 0 || result.getWidth() == 0) { result = new Bbox(); result.setX(Double.MIN_VALUE); result.setY(Double.MIN_VALUE); result.setMaxX(Double.MAX_VALUE); result.setMaxY(Double.MAX_VALUE); } return GeometryService.toPolygon(result); }