Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Best practices for zoom-dependent styling? #616

Unanswered
tylere asked this question in Q&A
Discussion options

What are the options / best practices for altering the styling of layers based on the zoom level?

One option could be to observe map widget event changes (similar to the following example), but is there a better approach?

m = lonboard.Map(layers)
def on_map_change(change):
 if change['name'] == '_property_lock':
 try:
 zoom = change['new']['view_state']['zoom']
 # code to manipulate layers
 layers[1].visible = (zoom < 1)
 except KeyError:
 pass 
m.observe(on_map_change)
You must be logged in to vote

Replies: 1 comment

Comment options

The easiest way is when the upstream deck.gl properties automatically support zoom-based styling. That is, for radius, there's radiusUnits that you can set to meters, which will automatically scale the radius at different zooms for roughly the same physical on-earth size.

Otherwise, I don't have great advice for the general case. I think what you have there is a good start!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /