-
-
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
base: master
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -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: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we need to handle
or
if we decide to use
-1
instead ofnull
which is not anumber
.@alexcjohnson your idea on which one is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With e722947 I changed the default to
-1
instead ofnull
. Scales with less than 0 make no sense here so this should be a valid solution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose
-1
as a default is OK if we really need a "no max" value - it's better thannull
which behaves oddly inrelayout
.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
10,000
?Similarly, is there a default we could use for minscale, to avoid zooming the whole map away to a point?
0.1
perhaps?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
(I'll have a look tomorrow. It's getting late her in europe 😴)