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) {
                break;
            }
            setZoom(zoom);
            rect = generateBoundingRect(positions, zoom);
        }
    }