We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent caf32e5 commit 423738fCopy full SHA for 423738f
src/components/modebar/buttons.js
@@ -548,8 +548,18 @@ function handleGeo(gd, ev) {
548
549
if(attr === 'zoom') {
550
var scale = geoLayout.projection.scale;
551
+ var minScale = geoLayout.projection.minScale;
552
+ var maxScale = geoLayout.projection.maxScale;
553
+
554
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale;
555
556
+ // 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;
561
+ }
562
563
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale);
564
}
565
src/plots/geo/geo.js
@@ -709,6 +709,14 @@ function getProjection(geoLayout) {
709
710
projection.precision(constants.precision);
711
712
+ // https://github.com/d3/d3-zoom/blob/master/README.md#zoom_scaleExtent
713
+ projection.scaleExtent = function() {
714
+ var minscale = projLayout.minscale;
715
+ var maxscale = projLayout.maxscale;
716
+ if(maxscale === -1) maxscale = Infinity;
717
+ return [100 * minscale, 100 * maxscale];
718
+ };
719
720
if(geoLayout._isSatellite) {
721
projection.tilt(projLayout.tilt).distance(projLayout.distance);
722
@@ -806,4 +814,4 @@ function makeRangeBox(lon, lat) {
806
814
[lon0, lat0]
807
815
]]
808
816
};
809
-}
817
+}
src/plots/geo/layout_attributes.js
@@ -177,6 +177,26 @@ var attrs = module.exports = overrideAll({
177
'that fits the map\'s lon and lat ranges. '
178
].join(' ')
179
},
180
+ minScale: {
181
+ valType: 'number',
182
+ min: 0,
183
+ dflt: 0,
184
+ description: [
185
+ 'Minimal zoom level of the map view.',
186
+ 'A minScale of *0.5* (50%) corresponds to a zoom level',
187
+ 'where the map has half the size of base zoom level.'
188
+ ].join(' ')
189
+ },
190
+ maxScale: {
191
192
193
+ dflt: Infinity,
194
195
+ 'Maximal zoom level of the map view.',
196
+ 'A maxScale of *2* (200%) corresponds to a zoom level',
197
+ 'where the map is twice as big as the base layer.'
198
199
200
201
center: {
202
lon: {
src/plots/geo/layout_defaults.js
@@ -161,6 +161,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
161
162
163
coerce('projection.scale');
164
+ coerce('projection.minScale');
165
+ coerce('projection.maxScale');
166
167
show = coerce('showland', !visible ? false : undefined);
168
if(show) coerce('landcolor');
@@ -205,6 +207,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
205
207
// clear attributes that will get auto-filled later
206
208
if(fitBounds) {
209
delete geoLayoutOut.projection.scale;
210
+ delete geoLayoutOut.projection.minScale;
211
+ delete geoLayoutOut.projection.maxScale;
212
213
if(isScoped) {
214
delete geoLayoutOut.center.lon;
src/plots/geo/zoom.js
@@ -32,6 +32,7 @@ module.exports = createGeoZoom;
32
function initZoom(geo, projection) {
33
return d3.behavior.zoom()
34
.translate(projection.translate())
35
+ .scaleExtent(projection.scaleExtent())
36
.scale(projection.scale());
37
38
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments