Add export_position option to the Draw plugin - #2271
Merged
hansthen merged 1 commit intoAug 23, 2026
Merged
Conversation
The export button was pinned to the top-right corner with hard-coded CSS, so it could sit on top of other controls -- a LayerControl in the same corner, for example (python-visualization#1806). Add an export_position parameter taking the four Leaflet corner names. It defaults to 'topright', which reproduces the previous placement exactly (top: 90px; right: 10px), so existing maps render unchanged. An unknown value raises a ValueError listing the valid corners. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1806.
The Draw plugin's export button is pinned to the top-right corner with hard-coded CSS (
right: 10px; top: 90px;), so it can end up overlapping another control in that corner — the issue mentions aLayerControlon the top right.This adds an
export_positionparameter taking the four Leaflet corner names (topright,topleft,bottomright,bottomleft):"topright", which reproduces the previous placement exactly —position: absolute; top: 90px; right: 10px;— so existing maps render unchanged.ValueErrorlisting the valid corners, rather than silently producing a button with no offsets.The corner → CSS mapping lives in a small module-level dict, and the template interpolates the resulting edge offsets in place of the old hard-coded lines.
Testing
Extended
tests/plugins/test_draw.py:test_draw_export_position_default— the default still emitstop: 90px+right: 10px.test_draw_export_position_corners— each corner emits its expected edge pair.test_draw_export_position_invalid— a bad value raisesValueError.tests/plugins/test_draw.pyis 6 passed.ruff checkandcodespellare clean on both files (ruff v0.16, matching the pinned hook). I left the pre-existingdraw.pytemplate formatting untouched.