@@ -9,6 +9,7 @@ var shapeLayer = L.geoJson(null);
9
9
10
10
const ORIG_W = 1000 ;
11
11
const ORIG_H = 1450 ;
12
+
12
13
// ######################################
13
14
// LEAFLET MAP
14
15
@@ -144,6 +145,8 @@ function changeDimensions(reset=false, preset=false) {
144
145
// console.log("chosen preset: " + $('#presets').val(), reset, preset);
145
146
var w ;
146
147
var h ;
148
+ var pagew = '21cm' ;
149
+ var pageh = '29.7cm' ;
147
150
if ( reset ) {
148
151
// console.log("resetting");
149
152
$ ( `.width` ) . val ( ORIG_W ) ;
@@ -166,34 +169,50 @@ function changeDimensions(reset=false, preset=false) {
166
169
case "A3_300" :
167
170
w = 4960 ;
168
171
h = 7016 ;
172
+ pagew = '29.7cm' ;
173
+ pageh = '42cm' ;
169
174
break ;
170
175
case "A3_150" :
171
176
w = 1754 ;
172
177
h = 2480 ;
178
+ pagew = '29.7cm' ;
179
+ pageh = '42cm' ;
173
180
break ;
174
181
case "A2_300" :
175
182
w = 4960 ;
176
183
h = 7016 ;
184
+ pagew = '42cm' ;
185
+ pageh = '59.4cm' ;
177
186
break ;
178
187
case "A2_150" :
179
188
w = 2480 ;
180
189
h = 3508 ;
190
+ pagew = '42cm' ;
191
+ pageh = '59.4cm' ;
181
192
break ;
182
193
case "A1_300" :
183
194
w = 7016 ;
184
195
h = 9933 ;
196
+ pagew = '59.4cm' ;
197
+ pageh = '84.1cm' ;
185
198
break ;
186
199
case "A1_150" :
187
200
w = 3508 ;
188
201
h = 4967 ;
202
+ pagew = '59.4cm' ;
203
+ pageh = '84.1cm' ;
189
204
break ;
190
205
case "A0_300" :
191
206
w = 9933 ;
192
207
h = 14043 ;
208
+ pagew = '84.1cm' ;
209
+ pageh = '118.9cm' ;
193
210
break ;
194
211
case "A0_150" :
195
212
w = 4967 ;
196
213
h = 7022 ;
214
+ pagew = '84.1cm' ;
215
+ pageh = '118.9cm' ;
197
216
break ;
198
217
}
199
218
$ ( `.width` ) . val ( w ) ;
@@ -206,6 +225,20 @@ function changeDimensions(reset=false, preset=false) {
206
225
$ ( `.page` ) . css ( 'width' , `${ w } px` ) ;
207
226
$ ( `.page` ) . css ( 'height' , `${ h } px` ) ;
208
227
228
+ // body cm height and width setting as per preset
229
+ var cssRules = document . querySelector ( 'style' ) . sheet . cssRules ;
230
+ for ( var i = 0 ; i < cssRules . length ; i ++ ) {
231
+ // Check if the rule is inside the @media print block
232
+ if ( cssRules [ i ] . media && cssRules [ i ] . media . mediaText === 'print' ) {
233
+ // Check if the rule targets the body element
234
+ if ( cssRules [ i ] . selectorText === 'body' ) {
235
+ // Change the width and height values
236
+ cssRules [ i ] . style . width = pagew ;
237
+ cssRules [ i ] . style . height = pageh ;
238
+ }
239
+ }
240
+ }
241
+
209
242
map . invalidateSize ( ) ;
210
243
// from https://stackoverflow.com/questions/24412325/resizing-a-leaflet-map-on-container-resize
211
244
//Checks if the map container size changed and updates the map if so — call it after you've changed the map size dynamically
0 commit comments