-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
add support for min/max scale limits #5192
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
Changes from all commits
a392b74
df23838
388c0b0
d531576
b0daf38
b46375a
c42cb9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -548,9 +548,22 @@ function handleGeo(gd, ev) { | |
|
||
if(attr === 'zoom') { | ||
var scale = geoLayout.projection.scale; | ||
var minscale = geoLayout.projection.minscale; | ||
var maxscale = geoLayout.projection.maxscale; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we need to handle if(maxscale === null) maxscale = Infinity; or if(maxscale === -1) maxscale = Infinity; if we decide to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With e722947 I changed the default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose But I wonder if we can't pick a decent default that's more zoomed in than is generally ever useful. I have occasionally gotten in a situation by accidentally scroll zooming so far in that everything freezes up because the SVG engine is having trouble drawing all the off-screen elements. If we cover 99% of cases and avoid this pitfall I'd say that's a reasonable tradeoff, and avoids making a coded value. Something like Similarly, is there a default we could use for minscale, to avoid zooming the whole map away to a point? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Makes sense! |
||
|
||
if(maxscale === -1) maxscale = Infinity; | ||
mojoaxel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale; | ||
|
||
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); | ||
// make sure the scale is within the min/max bounds | ||
if(newScale > maxscale) { | ||
mojoaxel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
newScale = maxscale; | ||
} else if(newScale < minscale) { | ||
newScale = minscale; | ||
} | ||
|
||
if(newScale !== scale) { | ||
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale); | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,26 @@ var attrs = module.exports = overrideAll({ | |
'that fits the map\'s lon and lat ranges. ' | ||
].join(' ') | ||
}, | ||
minscale: { | ||
valType: 'number', | ||
min: 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. Maybe it also make sense in some circumstances to only allow scaling between e.g. 2..3. Then of course the initial scale should also set so one value between 2..3. This check is still missing! What would be a good place to check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, layout_defaults is the right place - note that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also we probably need to check when the scale is automatically determined from the contents of the map whether it's within these bounds, and push it into the range if not. I'm not quite sure where that happens, possibly multiple places in geo.js depending on the situation. |
||
dflt: 0, | ||
description: [ | ||
'Minimal zoom level of the map view.', | ||
'A minscale of *0.5* (50%) corresponds to a zoom level', | ||
'where the map has half the size of base zoom level.' | ||
].join(' ') | ||
}, | ||
maxscale: { | ||
valType: 'number', | ||
min: 0, | ||
dflt: -1, | ||
description: [ | ||
'Maximal zoom level of the map view.', | ||
'A maxscale of *2* (200%) corresponds to a zoom level', | ||
'where the map is twice as big as the base layer.' | ||
].join(' ') | ||
}, | ||
}, | ||
center: { | ||
lon: { | ||
|