[Users] GeoExt.data.PrintPage: incorrect behaviour of method fit()?

Alexandre Saunier alexandre.saunier at camptocamp.com
Thu Aug 19 16:05:07 CEST 2010


Hello all,

I use GeoExt.ux.SimplePrint with a "autoFit:true" option to display
the largest print page extent that fits in the map.
However I keep getting one-size-too-large extents (page extent does
not fit in the map, the next scale in the list is the good one).

In GeoExt.data.PrintPage.fit() code (updated a few days ago), I have
noticed the following piece of code in the scales list iteration (see
[1]):

var bounds = this.calculatePageBounds(rec, units);
var contains = bounds.containsBounds(extent);
if (contains) {
      scale = rec;
}
=> the scale is updated only if the print extent is still larger than
the map. So when the print extent actually fits within the map, the
scale is not updated accordingly.
With the following patch, the print extent is fine:

Index: data/PrintPage.js
===================================================================
--- data/PrintPage.js   (revision 2275)
+++ data/PrintPage.js   (working copy)
@@ -202,9 +202,7 @@
         this.printProvider.scales.each(function(rec) {
             var bounds = this.calculatePageBounds(rec, units);
             var contains = bounds.containsBounds(extent);
-            if (contains) {
-                scale = rec;
-            }
+            scale = rec;
             if (loose) {
                 var diff = Math.min(
                     Math.abs(bounds.getWidth() - mapWidth),

Do I miss something?

Thanks for your help,
alex

[1] http://trac.geoext.org/browser/core/trunk/geoext/lib/GeoExt/data/PrintPage.js?rev=2275#L202


More information about the Users mailing list