@@ -90,12 +90,6 @@ export class Geomap {
90
90
if ( ! self . properties . height )
91
91
self . properties . height = self . properties . width / 1.92 ;
92
92
93
- if ( ! self . properties . scale )
94
- self . properties . scale = self . properties . width / 5.4 ;
95
-
96
- if ( ! self . properties . translate )
97
- self . properties . translate = [ self . properties . width / 2 , self . properties . height / 2 ] ;
98
-
99
93
self . svg = selection . append ( 'svg' )
100
94
. attr ( 'width' , self . properties . width )
101
95
. attr ( 'height' , self . properties . height ) ;
@@ -108,20 +102,25 @@ export class Geomap {
108
102
109
103
// Set map projection and path.
110
104
const proj = self . properties . projection ( )
111
- . scale ( self . properties . scale )
112
- . translate ( self . properties . translate )
113
105
. precision ( .1 ) ;
114
106
107
+ // Apply optional user settings to projection.
108
+ if ( self . properties . scale ) proj . scale ( self . properties . scale ) ;
109
+ if ( self . properties . translate ) proj . scale ( self . properties . translate ) ;
110
+
115
111
// Not every projection supports rotation, e. g. albersUsa does not.
116
112
if ( proj . hasOwnProperty ( 'rotate' ) && self . properties . rotate )
117
113
proj . rotate ( self . properties . rotate ) ;
118
114
119
115
self . path = geoPath ( ) . projection ( proj ) ;
120
-
121
116
const drawGeoData = geo => {
122
117
self . geo = geo ;
123
118
self . geoFeature = topoFeature ( geo , geo . objects [ self . properties . units ] ) ;
124
- proj . fitSize ( [ self . properties . width , self . properties . height ] , self . geoFeature ) ;
119
+
120
+ // Auto fit size if scale and translate are not set.
121
+ if ( self . properties . scale === null && self . properties . translate === null ) {
122
+ proj . fitSize ( [ self . properties . width , self . properties . height ] , self . geoFeature ) ;
123
+ }
125
124
126
125
self . svg . append ( 'g' ) . attr ( 'class' , 'units zoom' )
127
126
. selectAll ( 'path' )
0 commit comments