@@ -737,7 +737,8 @@ class VolumeImageViewer {
737737 resolutions : this [ _tileGrid ] . getResolutions ( ) ,
738738 rotation : this [ _rotation ] ,
739739 smoothResolutionConstraint : true ,
740- showFullExtent : true
740+ showFullExtent : true ,
741+ extent : this [ _referenceExtents ]
741742 } )
742743
743744 // Create a rendering engine object for offscreen rendering
@@ -846,7 +847,7 @@ class VolumeImageViewer {
846847 keyboardEventTarget : document
847848 } )
848849
849- view . fit ( this [ _projection ] . getExtent ( ) , this [ _map ] . getSize ( ) )
850+ view . fit ( this [ _projection ] . getExtent ( ) , { size : this [ _map ] . getSize ( ) } )
850851
851852 /**
852853 * OpenLayer's map has default active interactions
@@ -1391,7 +1392,7 @@ class VolumeImageViewer {
13911392 this [ _map ] . setTarget ( options . container )
13921393 const view = this [ _map ] . getView ( )
13931394 const projection = view . getProjection ( )
1394- view . fit ( projection . getExtent ( ) , this [ _map ] . getSize ( ) )
1395+ view . fit ( projection . getExtent ( ) , { size : this [ _map ] . getSize ( ) } )
13951396
13961397 // Style scale element (overriding default Openlayers CSS "ol-scale-line")
13971398 const scaleElement = this [ _controls ] . scale . element
@@ -1418,6 +1419,26 @@ class VolumeImageViewer {
14181419 scaleInnerElement . style . margin = '1px'
14191420 scaleInnerElement . style . willChange = 'contents,width'
14201421
1422+ const overviewElement = this [ _overviewMap ] . element
1423+ const overviewmapElement = Object . values ( overviewElement . children ) . find (
1424+ c => c . className === 'ol-overviewmap-map'
1425+ )
1426+ overviewmapElement . style . border = '1px solid black'
1427+ // Try to fit the overview map into the target control overlay container
1428+ const resizeFactor = 300
1429+ let width = Math . abs ( this [ _referenceExtents ] [ 1 ] ) / resizeFactor
1430+ let height = Math . abs ( this [ _referenceExtents ] [ 2 ] ) / resizeFactor
1431+ if ( width > 400 || height > 400 ) {
1432+ width /= 2
1433+ height /= 2
1434+ }
1435+ if ( width < 150 || height < 150 ) {
1436+ width *= 1.5
1437+ height *= 1.5
1438+ }
1439+ overviewmapElement . style . width = `${ width } px`
1440+ overviewmapElement . style . height = `${ height } px`
1441+
14211442 const container = this [ _map ] . getTargetElement ( )
14221443
14231444 this [ _drawingSource ] . on ( VectorEventType . ADDFEATURE , ( e ) => {
@@ -1724,6 +1745,10 @@ class VolumeImageViewer {
17241745 return
17251746 }
17261747 this [ _map ] . addControl ( this [ _overviewMap ] )
1748+ const map = this [ _overviewMap ] . getOverviewMap ( )
1749+ const view = map . getView ( )
1750+ const projection = view . getProjection ( )
1751+ view . fit ( projection . getExtent ( ) , { size : map . getSize ( ) } )
17271752 }
17281753
17291754 /**
@@ -2314,7 +2339,8 @@ class _NonVolumeImageViewer {
23142339 const view = new View ( {
23152340 center : getCenter ( extent ) ,
23162341 rotation : rotation ,
2317- projection : projection
2342+ projection : projection ,
2343+ extent : extent
23182344 } )
23192345
23202346 // Creates the map with the defined layers and view and renders it.
@@ -2325,7 +2351,7 @@ class _NonVolumeImageViewer {
23252351 keyboardEventTarget : document
23262352 } )
23272353
2328- view . fit ( projection . getExtent ( ) , this [ _map ] . getSize ( ) )
2354+ view . fit ( projection . getExtent ( ) , { size : this [ _map ] . getSize ( ) } )
23292355 }
23302356
23312357 /** Renders the image in the specified viewport container.
@@ -2339,7 +2365,7 @@ class _NonVolumeImageViewer {
23392365 this [ _map ] . setTarget ( options . container )
23402366 const view = this [ _map ] . getView ( )
23412367 const projection = view . getProjection ( )
2342- view . fit ( projection . getExtent ( ) , this [ _map ] . getSize ( ) )
2368+ view . fit ( projection . getExtent ( ) , { size : this [ _map ] . getSize ( ) } )
23432369
23442370 this [ _map ] . getInteractions ( ) . forEach ( ( interaction ) => {
23452371 this [ _map ] . removeInteraction ( interaction )
0 commit comments