Showing 1 changed files with 25 additions and 9 deletions
+25 -9
Nasal/map.nas
... ...
@@ -11,8 +11,8 @@ var MapTiles = {
11 11
         m.makeUrl = string.compileTemplate('https://{server}/{type}/{z}/{x}/{y}.png{apikey}');
12 12
         m.makePath = string.compileTemplate(m.maps_base ~ '/{server}/{type}/{z}/{x}/{y}.png');
13 13
         m.num_tiles = [
14
-            math.ceil( m.display.get('view[0]') / m.tile_size ) + 1,
15
-            math.ceil( m.display.get('view[1]') / m.tile_size ) + 1
14
+            math.ceil( m.device.data.mapsize[0] / m.tile_size ) + 1,
15
+            math.ceil( m.device.data.mapsize[1] / m.tile_size ) + 1
16 16
         ];
17 17
         m.center_tile_offset = [
18 18
             (m.num_tiles[0] - 1) / 2,
... ...
@@ -20,10 +20,20 @@ var MapTiles = {
20 20
         ];
21 21
         m.group = m.display.createGroup()
22 22
             .setCenter(
23
-                    m.display.get('view[0]') / 2,
24
-                    m.display.get('view[1]') / 2
25
-            )
26
-            .set('clip', 'rect(56,1024,742,148)'); # TODO use z-index (think INSET), or reorder code
23
+                    m.device.data.mapsize[0] / 2 + m.device.data.mapclip.left,
24
+                    m.device.data.mapsize[1] / 2 + m.device.data.mapclip.top
25
+                )
26
+            .setTranslation(
27
+                    m.device.data.mapclip.left / 2,
28
+                    m.device.data.mapclip.top / 2
29
+                )
30
+            .set('clip',
31
+                    'rect('
32
+                        ~ m.device.data.mapclip.top ~','
33
+                        ~ m.device.data.mapclip.right ~','
34
+                        ~ m.device.data.mapclip.bottom ~','
35
+                        ~ m.device.data.mapclip.left ~')'
36
+                );
27 37
         m.tiles = setsize([], m.num_tiles[0]);
28 38
         m.last_tile = [-1,-1];
29 39
         m.last_type = data['tiles-type'];
... ...
@@ -445,11 +455,17 @@ var PositionedLayer = {
445 455
         m.device = device;
446 456
         var display = m.device.display.display;
447 457
         m._group = display.createGroup().createChild('map', 'MFD map')
448
-            .set('clip', 'rect(56,1024,742,148)'); # TODO use z-index (think INSET), or reorder code
458
+            .set('clip',
459
+                    'rect('
460
+                        ~ m.device.data.mapclip.top ~','
461
+                        ~ m.device.data.mapclip.right ~','
462
+                        ~ m.device.data.mapclip.bottom ~','
463
+                        ~ m.device.data.mapclip.left ~')');
449 464
         m._group
450 465
             .setTranslation(
451
-                display.get('view[0]')/2,
452
-                display.get('view[1]')/2); # TODO compute from EIS size and screen size
466
+                    m.device.data.mapsize[0] / 2 + m.device.data.mapclip.left,
467
+                    m.device.data.mapsize[1] / 2 + m.device.data.mapclip.top
468
+                );
453 469
         m._group._node.getNode('range', 1)
454 470
             .setDoubleValue(13.5); # TODO find a far less esoteric way to get range value
455 471