コード例 #1
0
  @Override
  public void accept(PainterVisitor visitor, Object group, Bbox bounds, boolean recursive) {
    if (googleMap != null) {
      String sourceCrs = map.getMapModel().getCrs();
      if (isGoogleProjection(sourceCrs)) {
        int zoomLevel = calcZoomLevel(map.getMapModel().getMapView().getCurrentScale());
        Coordinate latLon = convertToLatLon(bounds.getCenterPoint());
        fitGoogleMapBounds(googleMap, latLon, zoomLevel);
      } else {
        // transform on server
        TransformGeometryRequest request = new TransformGeometryRequest();
        request.setBounds(
            new org.geomajas.geometry.Bbox(
                bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()));
        request.setSourceCrs(map.getMapModel().getCrs());
        request.setTargetCrs(EPSG_3857);
        GwtCommand command = new GwtCommand(TransformGeometryRequest.COMMAND);
        command.setCommandRequest(request);
        GwtCommandDispatcher.getInstance()
            .execute(
                command,
                new AbstractCommandCallback<TransformGeometryResponse>() {

                  public void execute(TransformGeometryResponse response) {
                    Bbox google = new Bbox(response.getBounds());
                    int zoomLevel = calcZoomLevelFromBounds(google);
                    fitGoogleMapBounds(
                        googleMap, convertToLatLon(google.getCenterPoint()), zoomLevel);
                  }
                });
      }
    }
  }