Skip to content

Commit ba04d0e

Browse files
committed
refactor: rename min/max scale limits
1 parent dbe591e commit ba04d0e

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

src/components/modebar/buttons.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -548,16 +548,16 @@ function handleGeo(gd, ev) {
548548

549549
if(attr === 'zoom') {
550550
var scale = geoLayout.projection.scale;
551-
var minScale = geoLayout.projection.minScale;
552-
var maxScale = geoLayout.projection.maxScale;
551+
var minscale = geoLayout.projection.minscale;
552+
var maxscale = geoLayout.projection.maxscale;
553553

554554
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale;
555555

556556
// make sure the scale is within the min/max bounds
557-
if(newScale > maxScale) {
558-
newScale = maxScale;
559-
} else if(newScale < minScale) {
560-
newScale = minScale;
557+
if(newScale > maxscale) {
558+
newScale = maxscale;
559+
} else if(newScale < minscale) {
560+
newScale = minscale;
561561
}
562562

563563
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale);

src/plots/geo/geo.js

+7
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,13 @@ function getProjection(geoLayout) {
747747

748748
projection.precision(constants.precision);
749749

750+
// https://github.com/d3/d3-zoom/blob/master/README.md#zoom_scaleExtent
751+
projection.scaleExtent = function () {
752+
var minscale = projLayout.minscale * 100;
753+
var maxscale = projLayout.maxscale * 100;
754+
return [minscale, maxscale];
755+
};
756+
750757
if (geoLayout._isSatellite) {
751758
projection.tilt(projLayout.tilt).distance(projLayout.distance);
752759
}

src/plots/geo/layout_attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ var attrs = module.exports = overrideAll({
177177
'that fits the map\'s lon and lat ranges. '
178178
].join(' ')
179179
},
180-
minScale: {
180+
minscale: {
181181
valType: 'number',
182182
role: 'info',
183183
min: 0,
@@ -188,11 +188,11 @@ var attrs = module.exports = overrideAll({
188188
'where the map has half the size of base zoom level.'
189189
].join(' ')
190190
},
191-
maxScale: {
191+
maxscale: {
192192
valType: 'number',
193193
role: 'info',
194194
min: 0,
195-
dflt: Infinity,
195+
dflt: null,
196196
description: [
197197
'Maximal zoom level of the map view.',
198198
'A maxScale of *2* (200%) corresponds to a zoom level',

src/plots/geo/layout_defaults.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
161161
}
162162

163163
coerce('projection.scale');
164-
coerce('projection.minScale');
165-
coerce('projection.maxScale');
164+
coerce('projection.minscale');
165+
coerce('projection.maxscale');
166166

167167
show = coerce('showland', !visible ? false : undefined);
168168
if(show) coerce('landcolor');
@@ -207,8 +207,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
207207
// clear attributes that will get auto-filled later
208208
if(fitBounds) {
209209
delete geoLayoutOut.projection.scale;
210-
delete geoLayoutOut.projection.minScale;
211-
delete geoLayoutOut.projection.maxScale;
210+
delete geoLayoutOut.projection.minscale;
211+
delete geoLayoutOut.projection.maxscale;
212212

213213
if(isScoped) {
214214
delete geoLayoutOut.center.lon;

0 commit comments

Comments
 (0)