code: public void calculateZoomFrom(Set<GeoPosition> positions)
      {
          // u.p("calculating a zoom based on: ");
          // u.p(positions);
          if (positions.size() < 2)
          {
              return;
          }
  
          int zoom = getZoom();
          Rectangle2D rect = generateBoundingRect(positions, zoom);
          // Rectangle2D viewport = map.getViewportBounds();
          int count = 0;
          while (!getViewportBounds().contains(rect))
          {
              // u.p("not contained");
              Point2D centr = new Point2D.Double(rect.getX() + rect.getWidth() / 2, rect.getY() + rect.getHeight() / 2);
              GeoPosition px = getTileFactory().pixelToGeo(centr, zoom);
              // u.p("new geo = " + px);
              setCenterPosition(px);
              count++;
              if (count > 30)
                  break;
  
              if (getViewportBounds().contains(rect))
              {
                  // u.p("did it finally");
                  break;
              }
              zoom = zoom + 1;
              if (zoom > 15) //TODO: use maxZoom of the tfInfo
              {
                  break;
              }
              setZoom(zoom);
              rect = generateBoundingRect(positions, zoom);
          }
      }
docs: Calculates a zoom level so that all points in the specified set will be visible on screen. This is useful if you
  have a bunch of points in an area like a city and you want to zoom out so that the entire city and it's points
  are visible without panning.
  @param positions A set of GeoPositions to calculate the new zoom from