8000 feat: Add min/max scale limits for geo plots by camdecoster · Pull Request #7371 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

feat: Add min/max scale limits for geo plots #7371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
refactor: rename min/max scale limits
  • Loading branch information
mojoaxel authored and camdecoster committed Feb 18, 2025
commit d870252e3e2d2838f39b6ca996f704fba106fefe
12 changes: 6 additions & 6 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,16 +543,16 @@ function handleGeo(gd, ev) {

if(attr === 'zoom') {
var scale = geoLayout.projection.scale;
var minScale = geoLayout.projection.minScale;
var maxScale = geoLayout.projection.maxScale;
var minscale = geoLayout.projection.minscale;
var maxscale = geoLayout.projection.maxscale;

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

// make sure the scale is within the min/max bounds
if(newScale > maxScale) {
newScale = maxScale;
} else if(newScale < minScale) {
newScale = minScale;
if(newScale > maxscale) {
newScale = maxscale;
} else if(newScale < minscale) {
newScale = minscale;
}

Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale);
Expand Down
6 changes: 3 additions & 3 deletions src/plots/geo/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var attrs = module.exports = overrideAll({
'that fits the map\'s lon and lat ranges. '
].join(' ')
},
minScale: {
minscale: {
valType: 'number',
min: 0,
dflt: 0,
Expand All @@ -187,10 +187,10 @@ var attrs = module.exports = overrideAll({
'where the map has half the size of base zoom level.'
].join(' ')
},
maxScale: {
maxscale: {
valType: 'number',
min: 0,
dflt: Infinity,
dflt: null,
description: [
'Maximal zoom level of the map view.',
'A maxScale of *2* (200%) corresponds to a zoom level',
Expand Down
8 changes: 4 additions & 4 deletions src/plots/geo/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
}

coerce('projection.scale');
coerce('projection.minScale');
coerce('projection.maxScale');
coerce('projection.minscale');
coerce('projection.maxscale');

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

if(isScoped) {
delete geoLayoutOut.center.lon;
Expand Down
0