Skip to content

Add export_position option to the Draw plugin - #2271

Merged
hansthen merged 1 commit into
python-visualization:mainfrom
Htet-Kaung-San:feature/draw-export-position
Aug 23, 2026
Merged

Add export_position option to the Draw plugin#2271
hansthen merged 1 commit into
python-visualization:mainfrom
Htet-Kaung-San:feature/draw-export-position

Conversation

@Htet-Kaung-San

Copy link
Copy Markdown
Contributor

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 a LayerControl on the top right.

This adds an export_position parameter taking the four Leaflet corner names (topright, topleft, bottomright, bottomleft):

Draw(export=True, export_position="topleft").add_to(m)
  • Default is "topright", which reproduces the previous placement exactlyposition: absolute; top: 90px; right: 10px; — so existing maps render unchanged.
  • An unknown value raises ValueError listing 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 emits top: 90px + right: 10px.
  • test_draw_export_position_corners — each corner emits its expected edge pair.
  • test_draw_export_position_invalid — a bad value raises ValueError.

tests/plugins/test_draw.py is 6 passed. ruff check and codespell are clean on both files (ruff v0.16, matching the pinned hook). I left the pre-existing draw.py template formatting untouched.

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>
@hansthen

Copy link
Copy Markdown
Collaborator

LGTM

@hansthen
hansthen merged commit f482fb0 into python-visualization:main Aug 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add position control for the Export button of Draw plugin

2 participants