[Commits] r2470 - in core/trunk/geoext: lib/GeoExt/widgets tests/lib/GeoExt/widgets
commits at geoext.org
commits at geoext.org
Mon Oct 25 18:57:01 CEST 2010
Author: ahocevar
Date: 2010-10-25 18:57:01 +0200 (Mon, 25 Oct 2010)
New Revision: 2470
Modified:
core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js
core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html
Log:
make sure that initial scale and extent of the PrintMapPanel is correct. r=fredj (closes #361)
Modified: core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js 2010-10-22 15:52:09 UTC (rev 2469)
+++ core/trunk/geoext/lib/GeoExt/widgets/PrintMapPanel.js 2010-10-25 16:57:01 UTC (rev 2470)
@@ -200,10 +200,21 @@
this.extent = this.sourceMap.getExtent();
GeoExt.PrintMapPanel.superclass.initComponent.call(this);
-
+ },
+
+ /** private: method[bind]
+ */
+ bind: function() {
+ this.printPage.on("change", this.fitZoom, this);
this.printProvider.on("layoutchange", this.syncSize, this);
- this.printPage.on("change", this.fitZoom, this);
this.map.events.register("moveend", this, this.updatePage);
+
+ this.printPage.fit(this.sourceMap);
+
+ if (this.initialConfig.limitScales === true) {
+ this.on("resize", this.calculatePreviewScales, this);
+ this.calculatePreviewScales();
+ }
},
/** private: method[afterRender]
@@ -212,19 +223,16 @@
afterRender: function() {
GeoExt.PrintMapPanel.superclass.afterRender.apply(this, arguments);
this.syncSize();
- if (this.initialConfig.limitScales === true) {
- if (!this.ownerCt) {
- this.calculatePreviewScales();
- } else {
- this.ownerCt.on({
- "afterlayout": {
- fn: this.calculatePreviewScales,
- scope: this,
- single: true
- }
- });
- }
- this.on("resize", this.calculatePreviewScales, this);
+ if (!this.ownerCt) {
+ this.bind();
+ } else {
+ this.ownerCt.on({
+ "afterlayout": {
+ fn: this.bind,
+ scope: this,
+ single: true
+ }
+ });
}
},
Modified: core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html
===================================================================
--- core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html 2010-10-22 15:52:09 UTC (rev 2469)
+++ core/trunk/geoext/tests/lib/GeoExt/widgets/PrintMapPanel.html 2010-10-25 16:57:01 UTC (rev 2470)
@@ -10,7 +10,7 @@
var printCapabilities = {"scales":[{"name":"1:25,000","value":"25000"},{"name":"1:50,000","value":"50000"},{"name":"1:100,000","value":"100000"},{"name":"1:200,000","value":"200000"},{"name":"1:500,000","value":"500000"},{"name":"1:1,000,000","value":"1000000"},{"name":"1:2,000,000","value":"2000000"},{"name":"1:4,000,000","value":"4000000"}],"dpis":[{"name":"75","value":"75"},{"name":"150","value":"150"},{"name":"300","value":"300"}],"layouts":[{"name":"A4 portrait","map":{"width":440,"height":483},"rotation":true},{"name":"Legal","map":{"width":440,"height":483},"rotation":false}],"printURL":"http://demo.opengeo.org/geoserver/pdf/print.pdf","createURL":"http://demo.opengeo.org/geoserver/pdf/create.json"};
function test_initComponent(t) {
- t.plan(6);
+ t.plan(8);
var mapPanel = new GeoExt.MapPanel({
renderTo: "mappanel",
@@ -53,6 +53,15 @@
t.eq((size.w/size.h).toPrecision(2), (printSize.width/printSize.height).toPrecision(2), "Aspect ratio of the preview map is the same as of the print layout.");
t.ok(Math.abs(center.lon - pageCenter.lon) < 0.0000001 && Math.abs(center.lat - pageCenter.lat) < 0.0000001, "Print page has the same center as the source map.");
+ var printExtent = printMapPanel.printPage.getPrintExtent(mapPanel.map);
+ t.ok(printMapPanel.map.getExtent().containsBounds(printExtent), "Preview contains the extent of the source map.");
+
+ var page = printMapPanel.printPage;
+ var scale = page.scale;
+ var scales = printMapPanel.previewScales;
+ page.setScale(scales.getAt(scales.indexOf(scale)+1));
+ t.ok(!printMapPanel.map.getExtent().containsBounds(printExtent), "After zooming in, preview does not contain the extent of the source map any more.");
+
printMapPanel.destroy();
mapPanel.destroy();
}
More information about the Commits
mailing list