mapyta 0.3.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. mapyta-0.4.0/.github/workflows/docs-preview.yml +76 -0
  2. mapyta-0.4.0/.github/workflows/docs.yml +30 -0
  3. {mapyta-0.3.0 → mapyta-0.4.0}/.github/workflows/lint.yml +1 -1
  4. {mapyta-0.3.0 → mapyta-0.4.0}/.github/workflows/publish.yml +1 -1
  5. {mapyta-0.3.0 → mapyta-0.4.0}/.github/workflows/tests.yml +1 -1
  6. {mapyta-0.3.0 → mapyta-0.4.0}/.gitignore +4 -0
  7. {mapyta-0.3.0 → mapyta-0.4.0}/PKG-INFO +1 -1
  8. mapyta-0.4.0/docs/tutorial/choropleth.md +216 -0
  9. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/clusters.md +3 -3
  10. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/export.md +15 -0
  11. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/faq.md +69 -0
  12. mapyta-0.4.0/docs/tutorial/layers.md +102 -0
  13. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/min-zoom.md +1 -1
  14. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/tooltips-popups.md +31 -0
  15. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/__init__.py +2 -0
  16. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/export.py +10 -0
  17. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/map.py +293 -77
  18. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/style.py +15 -0
  19. {mapyta-0.3.0 → mapyta-0.4.0}/pyproject.toml +1 -1
  20. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_export.py +63 -1
  21. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_geometry.py +2 -2
  22. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_layers.py +3 -3
  23. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_map.py +466 -8
  24. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_utilities.py +2 -2
  25. {mapyta-0.3.0 → mapyta-0.4.0}/uv.lock +5 -1
  26. mapyta-0.3.0/.github/workflows/docs.yml +0 -36
  27. mapyta-0.3.0/docs/tutorial/choropleth.md +0 -65
  28. mapyta-0.3.0/docs/tutorial/layers.md +0 -44
  29. {mapyta-0.3.0 → mapyta-0.4.0}/.pre-commit-config.yaml +0 -0
  30. {mapyta-0.3.0 → mapyta-0.4.0}/.ruff.toml +0 -0
  31. {mapyta-0.3.0 → mapyta-0.4.0}/LICENSE +0 -0
  32. {mapyta-0.3.0 → mapyta-0.4.0}/README.md +0 -0
  33. {mapyta-0.3.0 → mapyta-0.4.0}/docs/.nav.yml +0 -0
  34. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/assets/images/favicon.ico +0 -0
  35. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/assets/images/logo-dark-mode.svg +0 -0
  36. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/assets/images/mapyta-logo-dark-mode.svg +0 -0
  37. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/assets/images/mapyta-logo-light-mode.svg +0 -0
  38. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/assets/javascripts/katex.js +0 -0
  39. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/assets/stylesheets/extra.css +0 -0
  40. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_overrides/main.html +0 -0
  41. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_scripts/__init__.py +0 -0
  42. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_scripts/generate_index.py +0 -0
  43. {mapyta-0.3.0 → mapyta-0.4.0}/docs/_scripts/generate_reference_pages.py +0 -0
  44. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/.nav.yml +0 -0
  45. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/advanced.md +0 -0
  46. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/animated.md +0 -0
  47. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/configuration.md +0 -0
  48. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/coordinates.md +0 -0
  49. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/dataframe.md +0 -0
  50. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/drawing.md +0 -0
  51. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/first-map.md +0 -0
  52. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/geodataframe.md +0 -0
  53. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/geometries.md +0 -0
  54. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/heatmaps.md +0 -0
  55. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/index.md +0 -0
  56. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/markers.md +0 -0
  57. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/open-data.md +0 -0
  58. {mapyta-0.3.0 → mapyta-0.4.0}/docs/tutorial/text-annotations.md +0 -0
  59. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/config.py +0 -0
  60. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/coordinates.py +0 -0
  61. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/dataframe.py +0 -0
  62. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/geojson.py +0 -0
  63. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/markdown.py +0 -0
  64. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/markers.py +0 -0
  65. {mapyta-0.3.0 → mapyta-0.4.0}/mapyta/tiles.py +0 -0
  66. {mapyta-0.3.0 → mapyta-0.4.0}/properdocs.yml +0 -0
  67. {mapyta-0.3.0 → mapyta-0.4.0}/tests/__init__.py +0 -0
  68. {mapyta-0.3.0 → mapyta-0.4.0}/tests/conftest.py +0 -0
  69. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_data.py +0 -0
  70. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_dataframe.py +0 -0
  71. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_draw.py +0 -0
  72. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_map_creation.py +0 -0
  73. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_markers.py +0 -0
  74. {mapyta-0.3.0 → mapyta-0.4.0}/tests/test_merge_and_chaining.py +0 -0
@@ -0,0 +1,76 @@
1
+ name: Docs preview
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, reopened, synchronize, closed]
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+
11
+ concurrency:
12
+ group: docs-preview-pr-${{ github.event.pull_request.number }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ preview:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+
21
+ - if: github.event.action != 'closed'
22
+ uses: astral-sh/setup-uv@v5
23
+ with:
24
+ python-version: "3.13"
25
+
26
+ - if: github.event.action != 'closed'
27
+ name: Install docs dependencies
28
+ run: uv sync --group docs
29
+
30
+ - if: github.event.action != 'closed'
31
+ name: Build docs
32
+ run: uv run properdocs build --clean --strict
33
+
34
+ - name: Deploy preview
35
+ if: github.event.action != 'closed'
36
+ uses: JamesIves/github-pages-deploy-action@v4
37
+ with:
38
+ folder: site
39
+ target-folder: pr-preview/pr-${{ github.event.pull_request.number }}
40
+ clean: false
41
+
42
+ - name: Comment preview URL
43
+ if: github.event.action != 'closed'
44
+ uses: actions/github-script@v7
45
+ with:
46
+ script: |
47
+ const url = `https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/`;
48
+ const body = `## 📖 Docs preview\n\n🔗 ${url}\n\n_Updated on every push. Removed when the PR is closed._`;
49
+ const { data: comments } = await github.rest.issues.listComments({
50
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number,
51
+ });
52
+ const bot = comments.find(c => c.user.type === 'Bot' && c.body.includes('Docs preview'));
53
+ if (bot) {
54
+ await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: bot.id, body });
55
+ } else {
56
+ await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body });
57
+ }
58
+
59
+ - name: Remove preview on close
60
+ if: github.event.action == 'closed'
61
+ env:
62
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63
+ run: |
64
+ # Skip if gh-pages branch doesn't exist yet
65
+ git ls-remote --heads https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git gh-pages \
66
+ | grep -q gh-pages || exit 0
67
+ PR_NUM=${{ github.event.pull_request.number }}
68
+ git clone --depth=1 --branch=gh-pages \
69
+ https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git /tmp/gh-pages
70
+ rm -rf /tmp/gh-pages/pr-preview/pr-${PR_NUM}
71
+ cd /tmp/gh-pages
72
+ git config user.email "github-actions[bot]@users.noreply.github.com"
73
+ git config user.name "github-actions[bot]"
74
+ git add -A
75
+ git diff --quiet HEAD || git commit -m "chore: remove docs preview for PR #${PR_NUM}"
76
+ git push
@@ -0,0 +1,30 @@
1
+ name: Publish docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: write
9
+
10
+ jobs:
11
+ docs:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v5
15
+
16
+ - uses: astral-sh/setup-uv@v5
17
+ with:
18
+ python-version: "3.13"
19
+
20
+ - name: Install docs dependencies
21
+ run: uv sync --group docs
22
+
23
+ - name: Build docs
24
+ run: uv run properdocs build --clean --strict
25
+
26
+ - name: Deploy to GitHub Pages
27
+ uses: JamesIves/github-pages-deploy-action@v4
28
+ with:
29
+ folder: site
30
+ clean-exclude: pr-preview
@@ -10,7 +10,7 @@ jobs:
10
10
  lint:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v4
13
+ - uses: actions/checkout@v5
14
14
 
15
15
  - uses: astral-sh/setup-uv@v5
16
16
  with:
@@ -13,7 +13,7 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  environment: pypi
15
15
  steps:
16
- - uses: actions/checkout@v4
16
+ - uses: actions/checkout@v5
17
17
 
18
18
  - uses: astral-sh/setup-uv@v5
19
19
  with:
@@ -10,7 +10,7 @@ jobs:
10
10
  tests:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v4
13
+ - uses: actions/checkout@v5
14
14
 
15
15
  - uses: astral-sh/setup-uv@v5
16
16
  with:
@@ -11,3 +11,7 @@ site
11
11
  # Virtual environments
12
12
  .venv
13
13
  venv
14
+
15
+ # Test coverage
16
+ .coverage
17
+ htmlcov/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapyta
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Mapyta, open source python package for GIS mapping and visualization.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -0,0 +1,216 @@
1
+ # Choropleth Maps
2
+
3
+ A "choropleth" is a map where areas are shaded by a numeric value, think population density, liveability scores, or soil classifications. Map builds one from a GeoJSON FeatureCollection and a value column.
4
+
5
+ ```python exec="true" html="true" source="tabbed-right"
6
+ from mapyta import Map
7
+
8
+ geojson = {
9
+ "type": "FeatureCollection",
10
+ "features": [
11
+ {
12
+ "type": "Feature",
13
+ "properties": {"name": "Binnenstad", "score": 92},
14
+ "geometry": {
15
+ "type": "Polygon",
16
+ "coordinates": [[[5.10, 52.08], [5.14, 52.08], [5.14, 52.10], [5.10, 52.10], [5.10, 52.08]]],
17
+ },
18
+ },
19
+ {
20
+ "type": "Feature",
21
+ "properties": {"name": "West", "score": 74},
22
+ "geometry": {
23
+ "type": "Polygon",
24
+ "coordinates": [[[5.06, 52.08], [5.10, 52.08], [5.10, 52.10], [5.06, 52.10], [5.06, 52.08]]],
25
+ },
26
+ },
27
+ {
28
+ "type": "Feature",
29
+ "properties": {"name": "Oost", "score": 85},
30
+ "geometry": {
31
+ "type": "Polygon",
32
+ "coordinates": [[[5.14, 52.08], [5.18, 52.08], [5.18, 52.10], [5.14, 52.10], [5.14, 52.08]]],
33
+ },
34
+ },
35
+ ],
36
+ }
37
+
38
+ m = Map(title="Neighbourhood Scores")
39
+ m.add_choropleth(
40
+ geojson_data=geojson,
41
+ value_column="score",
42
+ key_on="feature.properties.name",
43
+ legend_name="Liveability Score",
44
+ hover_fields=["name", "score"],
45
+ fill_opacity=0.7,
46
+ )
47
+
48
+ m.to_html("choropleth.html")
49
+
50
+ print(m.to_html()) # markdown-exec: hide
51
+ ```
52
+
53
+ ## How it works
54
+
55
+ **`value_column`** tells Map which GeoJSON property holds the numeric value.
56
+
57
+ **`key_on`** is the dot-path to the join key inside each feature (Folium convention). For properties it's always `"feature.properties.<key>"`.
58
+
59
+ If you don't pass `values` explicitly, Map reads them straight from the GeoJSON properties, which is usually what you want.
60
+
61
+ **`hover_fields`** turns property keys into a tooltip table on mouse-over.
62
+
63
+ !!! tip "Multiple ways to pass GeoJSON"
64
+
65
+ `geojson_data` accepts a dict, a JSON string, or a `Path` to a `.geojson` file, Map handles all three.
66
+
67
+ ## Custom color palettes
68
+
69
+ By default choropleths use a yellow-to-red gradient (`"ylrd"`). Pass a named palette or a list of hex colors to the `colors` parameter:
70
+
71
+ ```python exec="true" html="true" source="tabbed-right"
72
+ from mapyta import Map
73
+
74
+ geojson = {
75
+ "type": "FeatureCollection",
76
+ "features": [
77
+ {
78
+ "type": "Feature",
79
+ "properties": {"name": "Binnenstad", "score": 92},
80
+ "geometry": {
81
+ "type": "Polygon",
82
+ "coordinates": [[[5.10, 52.08], [5.14, 52.08], [5.14, 52.10], [5.10, 52.10], [5.10, 52.08]]],
83
+ },
84
+ },
85
+ {
86
+ "type": "Feature",
87
+ "properties": {"name": "West", "score": 74},
88
+ "geometry": {
89
+ "type": "Polygon",
90
+ "coordinates": [[[5.06, 52.08], [5.10, 52.08], [5.10, 52.10], [5.06, 52.10], [5.06, 52.08]]],
91
+ },
92
+ },
93
+ {
94
+ "type": "Feature",
95
+ "properties": {"name": "Oost", "score": 85},
96
+ "geometry": {
97
+ "type": "Polygon",
98
+ "coordinates": [[[5.14, 52.08], [5.18, 52.08], [5.18, 52.10], [5.14, 52.10], [5.14, 52.08]]],
99
+ },
100
+ },
101
+ ],
102
+ }
103
+
104
+ m = Map(title="Neighbourhood Scores — Blues palette")
105
+ m.add_choropleth(
106
+ geojson_data=geojson,
107
+ value_column="score",
108
+ key_on="feature.properties.name",
109
+ legend_name="Liveability Score",
110
+ hover_fields=["name", "score"],
111
+ fill_opacity=0.7,
112
+ colors="blues",
113
+ )
114
+
115
+ print(m.to_html()) # markdown-exec: hide
116
+ ```
117
+
118
+ You can also pass a custom list of hex colors (ordered from low to high values):
119
+
120
+ ```python exec="true" html="true" source="tabbed-right"
121
+ from mapyta import Map
122
+
123
+ geojson = {
124
+ "type": "FeatureCollection",
125
+ "features": [
126
+ {
127
+ "type": "Feature",
128
+ "properties": {"name": "Binnenstad", "score": 92},
129
+ "geometry": {
130
+ "type": "Polygon",
131
+ "coordinates": [[[5.10, 52.08], [5.14, 52.08], [5.14, 52.10], [5.10, 52.10], [5.10, 52.08]]],
132
+ },
133
+ },
134
+ {
135
+ "type": "Feature",
136
+ "properties": {"name": "West", "score": 74},
137
+ "geometry": {
138
+ "type": "Polygon",
139
+ "coordinates": [[[5.06, 52.08], [5.10, 52.08], [5.10, 52.10], [5.06, 52.10], [5.06, 52.08]]],
140
+ },
141
+ },
142
+ {
143
+ "type": "Feature",
144
+ "properties": {"name": "Oost", "score": 85},
145
+ "geometry": {
146
+ "type": "Polygon",
147
+ "coordinates": [[[5.14, 52.08], [5.18, 52.08], [5.18, 52.10], [5.14, 52.10], [5.14, 52.08]]],
148
+ },
149
+ },
150
+ ],
151
+ }
152
+
153
+ m = Map(title="Neighbourhood Scores — Custom colors")
154
+ m.add_choropleth(
155
+ geojson_data=geojson,
156
+ value_column="score",
157
+ key_on="feature.properties.name",
158
+ legend_name="Liveability Score",
159
+ hover_fields=["name", "score"],
160
+ fill_opacity=0.7,
161
+ colors=["#f7fbff", "#6baed6", "#084594"],
162
+ )
163
+
164
+ print(m.to_html()) # markdown-exec: hide
165
+ ```
166
+
167
+ All available palette names are exposed in `mapyta.PALETTES`:
168
+
169
+ ```python exec="true" result="ansi" source="tabbed-right"
170
+ from mapyta import PALETTES
171
+
172
+ print(list(PALETTES.keys()))
173
+ ```
174
+
175
+ The same `colors` parameter works on `Map.from_geodataframe()` when using `color_column`.
176
+
177
+ ## Categorical data
178
+
179
+ If your values are string categories (land use type, municipality class, etc.), set `categorical=True` or pass string values and mapyta auto-detects them. Each unique category gets a distinct color from the palette:
180
+
181
+ ```python exec="true" html="true" source="tabbed-right"
182
+ from mapyta import Map
183
+
184
+ geojson = {
185
+ "type": "FeatureCollection",
186
+ "features": [
187
+ {
188
+ "type": "Feature",
189
+ "properties": {"name": "Binnenstad", "type": "urban"},
190
+ "geometry": {"type": "Polygon", "coordinates": [[[5.10, 52.08], [5.14, 52.08], [5.14, 52.10], [5.10, 52.10], [5.10, 52.08]]]},
191
+ },
192
+ {
193
+ "type": "Feature",
194
+ "properties": {"name": "West", "type": "suburban"},
195
+ "geometry": {"type": "Polygon", "coordinates": [[[5.06, 52.08], [5.10, 52.08], [5.10, 52.10], [5.06, 52.10], [5.06, 52.08]]]},
196
+ },
197
+ {
198
+ "type": "Feature",
199
+ "properties": {"name": "Oost", "type": "urban"},
200
+ "geometry": {"type": "Polygon", "coordinates": [[[5.14, 52.08], [5.18, 52.08], [5.18, 52.10], [5.14, 52.10], [5.14, 52.08]]]},
201
+ },
202
+ ],
203
+ }
204
+
205
+ m = Map(title="Area Types")
206
+ m.add_choropleth(
207
+ geojson_data=geojson,
208
+ value_column="type",
209
+ key_on="feature.properties.name",
210
+ legend_name="Area type",
211
+ colors="spectral",
212
+ hover_fields=["name", "type"],
213
+ )
214
+
215
+ print(m.to_html()) # markdown-exec: hide
216
+ ```
@@ -10,10 +10,10 @@ from mapyta import Map
10
10
  random.seed(42)
11
11
  cafes = [Point(5.12 + random.uniform(-0.02, 0.02), 52.09 + random.uniform(-0.01, 0.01)) for _ in range(50)]
12
12
  labels = ["☕"] * 50
13
- hovers = [f"**Café #{i + 1}**" for i in range(50)]
13
+ tooltips = [f"**Café #{i + 1}**" for i in range(50)]
14
14
 
15
15
  m = Map(title="Utrecht Cafés")
16
- m.add_marker_cluster(points=cafes, labels=labels, hovers=hovers, name="Cafés")
16
+ m.add_marker_cluster(points=cafes, labels=labels, tooltips=tooltips, name="Cafés")
17
17
 
18
18
  m.to_html("clusters.html")
19
19
 
@@ -28,7 +28,7 @@ At low zoom you'll see cluster bubbles with counts. Zoom in and they split into
28
28
  |-----------|-------------|
29
29
  | `points` | List of Shapely `Point` objects |
30
30
  | `labels` | Marker text per point (emoji, text, or FA icon name) |
31
- | `hovers` | Markdown tooltip per point |
31
+ | `tooltips` | Markdown tooltip per point |
32
32
  | `popups` | Markdown popup per point |
33
33
  | `captions` | Text label below each marker |
34
34
  | `marker_style` | CSS dict applied to all markers |
@@ -42,6 +42,21 @@ buf = m.to_bytesio(width=1200, height=800)
42
42
 
43
43
  The `delay` parameter (seconds) controls how long Map waits for tiles to load before taking the screenshot. Increase it on slow connections.
44
44
 
45
+ ### High-DPI / print-quality export
46
+
47
+ Use the `scale` parameter to produce a higher-resolution PNG without changing the map layout:
48
+
49
+ ```python
50
+ # 2× resolution (2400 × 1600 px output from a 1200 × 800 viewport)
51
+ m.to_image("map_hd.png", width=1200, height=800, scale=2.0)
52
+
53
+ # Same for BytesIO and async
54
+ buf = m.to_bytesio(width=1600, height=900, scale=2.0)
55
+ png_bytes = await m.to_image_async(width=1600, height=900, scale=2.0)
56
+ ```
57
+
58
+ `scale=1.0` is the default (no change). `scale=2.0` is suitable for most print use cases.
59
+
45
60
  ## GeoJSON
46
61
 
47
62
  Export all features added to the map as a GeoJSON `FeatureCollection`:
@@ -177,6 +177,62 @@ m.add_layer_control()
177
177
 
178
178
  ---
179
179
 
180
+ ## Choropleth & colors
181
+
182
+ **How do I customise the colors of a choropleth?**
183
+
184
+ Pass a palette name or a list of hex colors to the `colors` parameter:
185
+
186
+ ```python
187
+ # Named palette (see mapyta.PALETTES for all options)
188
+ m.add_choropleth(geojson, value_column="score", key_on="feature.properties.id", colors="blues")
189
+
190
+ # Custom colors (low → high)
191
+ m.add_choropleth(geojson, value_column="score", key_on="feature.properties.id", colors=["#eef", "#44f", "#004"])
192
+ ```
193
+
194
+ The same `colors` parameter works on `Map.from_geodataframe(color_column=...)`.
195
+
196
+ ---
197
+
198
+ **How do I create a choropleth with categorical (non-numeric) data?**
199
+
200
+ Just use string values. Mapyta auto-detects them and assigns a distinct color per category:
201
+
202
+ ```python
203
+ # String values → auto-detected as categorical
204
+ m.add_choropleth(geojson, value_column="land_use", key_on="feature.properties.id")
205
+
206
+ # Force categorical mode explicitly
207
+ m.add_choropleth(geojson, value_column="score", key_on="feature.properties.id", categorical=True)
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Search
213
+
214
+ **How do I add a search box to the map?**
215
+
216
+ Use `add_search_control()`. The layer must be in a feature group:
217
+
218
+ ```python
219
+ geojson = {
220
+ "type": "FeatureCollection",
221
+ "features": [
222
+ {"type": "Feature", "properties": {"name": "Amsterdam", "score": 1}, "geometry": {"type": "Point", "coordinates": [4.9, 52.37]}},
223
+ {"type": "Feature", "properties": {"name": "Utrecht", "score": 2}, "geometry": {"type": "Point", "coordinates": [5.12, 52.09]}},
224
+ ],
225
+ }
226
+
227
+ m.create_feature_group("Places")
228
+ m.add_choropleth(geojson, value_column="score", key_on="feature.properties.name")
229
+ m.reset_target()
230
+
231
+ m.add_search_control(layer_name="Places", property_name="name", zoom=14)
232
+ ```
233
+
234
+ ---
235
+
180
236
  ## Export
181
237
 
182
238
  **How do I save the map to an HTML file?**
@@ -211,6 +267,19 @@ Chrome or Chromium must be installed.
211
267
 
212
268
  ---
213
269
 
270
+ **How do I export a higher-resolution PNG for print or presentations?**
271
+
272
+ Use the `scale` parameter:
273
+
274
+ ```python
275
+ # 2× resolution (2400 × 1600 px from a 1200 × 800 layout)
276
+ m.to_image("map_print.png", width=1200, height=800, scale=2.0)
277
+ ```
278
+
279
+ `scale=2.0` doubles the pixel dimensions without changing the map layout.
280
+
281
+ ---
282
+
214
283
  **How do I export the map features as GeoJSON?**
215
284
 
216
285
  ```python
@@ -0,0 +1,102 @@
1
+ # Feature Groups
2
+
3
+ When your map has multiple categories of data, you want users to toggle them on and off. That's what "feature groups" are for, think of them as named folders. Everything you add while a group is active goes into that folder.
4
+
5
+ ```python exec="true" html="true" source="tabbed-right"
6
+ from shapely.geometry import Point
7
+ from mapyta import Map
8
+
9
+ m = Map(title="Utrecht POI")
10
+
11
+ # Group 1: Museums
12
+ m.create_feature_group("🏛️ Museums")
13
+ m.add_point(point=Point(5.1178, 52.0865), marker="🖼️", tooltip="**Centraal Museum**")
14
+ m.add_point(point=Point(5.1197, 52.0820), marker="🚂", tooltip="**Spoorwegmuseum**")
15
+
16
+ # Group 2: Parks
17
+ m.create_feature_group("🌳 Parks")
18
+ m.add_point(point=Point(5.1248, 52.0855), marker="🌳", tooltip="**Wilhelminapark**")
19
+ m.add_point(point=Point(5.1367, 52.0945), marker="🌿", tooltip="**Griftpark**")
20
+
21
+ m.add_layer_control(collapsed=False)
22
+
23
+ m.to_html("poi_layers.html")
24
+
25
+ print(m.to_html()) # markdown-exec: hide
26
+ ```
27
+
28
+ ## How it works
29
+
30
+ **`create_feature_group("name")`** creates a new group and immediately activates it. All subsequent `add_*` calls go into this group until you:
31
+
32
+ - Call `create_feature_group()` again to create and switch to a new group
33
+ - Call `set_feature_group("name")` to switch to an existing group
34
+ - Call `reset_target()` to go back to the base map
35
+
36
+ **`add_layer_control()`** adds the toggle widget in the corner. Set `collapsed=False` to show it expanded by default.
37
+
38
+ !!! tip "Hiding groups by default"
39
+
40
+ Pass `show=False` to `create_feature_group()` to have a layer hidden when the map loads:
41
+
42
+ ```python
43
+ m.create_feature_group("🔵 Boreholes", show=False)
44
+ ```
45
+
46
+ ## Search control
47
+
48
+ `add_search_control()` adds a search box that lets users find a feature in a feature group by one of its properties:
49
+
50
+ ```python exec="true" html="true" source="tabbed-right"
51
+ from mapyta import Map
52
+
53
+ geojson = {
54
+ "type": "FeatureCollection",
55
+ "features": [
56
+ {
57
+ "type": "Feature",
58
+ "properties": {"name": "Binnenstad", "score": 92},
59
+ "geometry": {"type": "Polygon", "coordinates": [[[5.10, 52.08], [5.14, 52.08], [5.14, 52.10], [5.10, 52.10], [5.10, 52.08]]]},
60
+ },
61
+ {
62
+ "type": "Feature",
63
+ "properties": {"name": "West", "score": 74},
64
+ "geometry": {"type": "Polygon", "coordinates": [[[5.06, 52.08], [5.10, 52.08], [5.10, 52.10], [5.06, 52.10], [5.06, 52.08]]]},
65
+ },
66
+ {
67
+ "type": "Feature",
68
+ "properties": {"name": "Oost", "score": 85},
69
+ "geometry": {"type": "Polygon", "coordinates": [[[5.14, 52.08], [5.18, 52.08], [5.18, 52.10], [5.14, 52.10], [5.14, 52.08]]]},
70
+ },
71
+ ],
72
+ }
73
+
74
+ m = Map(title="Neighbourhood Finder")
75
+
76
+ # Add the choropleth to a named feature group so it can be searched
77
+ m.create_feature_group("Neighbourhoods")
78
+ m.add_choropleth(
79
+ geojson_data=geojson,
80
+ value_column="score",
81
+ key_on="feature.properties.name",
82
+ legend_name="Liveability Score",
83
+ hover_fields=["name", "score"],
84
+ )
85
+ m.reset_target()
86
+
87
+ m.add_search_control(
88
+ layer_name="Neighbourhoods",
89
+ property_name="name", # GeoJSON property to match against
90
+ placeholder="Find neighbourhood...",
91
+ zoom=14, # zoom level when a result is selected
92
+ geom_type="Polygon", # use "Polygon" for area features
93
+ )
94
+
95
+ print(m.to_html()) # markdown-exec: hide
96
+ ```
97
+
98
+ **`layer_name`** must match the name used in `create_feature_group()`. **`property_name`** is the GeoJSON property to search on — it must exist on your features. Use `geom_type="Polygon"` when searching polygon or choropleth layers. The control uses `folium.plugins.Search` internally.
99
+
100
+ !!! note
101
+
102
+ `add_search_control()` searches the GeoJSON properties of features in the given feature group. The feature group must contain a GeoJSON layer (e.g. added via `add_choropleth`) so that property-based search works correctly.
@@ -107,7 +107,7 @@ from mapyta import Map
107
107
  m = Map()
108
108
 
109
109
  for geom in [Point(5.12, 52.09), LineString([(5.11, 52.09), (5.13, 52.09)])]:
110
- m.add_geometry(geom, hover="Zoom in to see me", min_zoom=14)
110
+ m.add_geometry(geom, tooltip="Zoom in to see me", min_zoom=14)
111
111
 
112
112
  print(m.to_html()) # markdown-exec: hide
113
113
  ```
@@ -61,3 +61,34 @@ print(m.to_html()) # markdown-exec: hide
61
61
  !!! tip
62
62
 
63
63
  `RawHTML` works on both `tooltip` and `popup` parameters across all `add_*` methods.
64
+
65
+ ## Tooltip style
66
+
67
+ `TooltipStyle` controls the appearance of the tooltip box. Pass it to any `add_*` geometry method:
68
+
69
+ ```python
70
+ from shapely.geometry import LineString, Polygon, Point
71
+ from mapyta import Map, TooltipStyle
72
+
73
+ m = Map()
74
+
75
+ m.add_point(
76
+ Point(4.9, 52.37),
77
+ tooltip="**Amsterdam**",
78
+ tooltip_style=TooltipStyle(sticky=False, style="font-size: 14px; font-weight: bold;"),
79
+ )
80
+
81
+ m.add_linestring(
82
+ LineString([(4.9, 52.37), (5.0, 52.38)]),
83
+ tooltip="Route A → B",
84
+ tooltip_style=TooltipStyle(sticky=True),
85
+ )
86
+
87
+ m.add_polygon(
88
+ Polygon([(4.9, 52.3), (5.0, 52.3), (5.0, 52.4), (4.9, 52.4)]),
89
+ tooltip="Zone",
90
+ tooltip_style={"sticky": False, "style": "color: red;"},
91
+ )
92
+ ```
93
+
94
+ `sticky=True` (default) means the tooltip follows the cursor. `sticky=False` pins the tooltip to the feature. The `style` field takes a raw CSS string applied to the tooltip container.
@@ -3,9 +3,11 @@
3
3
  from mapyta.config import CircleStyle, DrawConfig, DrawTool, FillStyle, HeatmapStyle, MapConfig, PopupStyle, RawJS, StrokeStyle, TooltipStyle
4
4
  from mapyta.map import Map
5
5
  from mapyta.markdown import RawHTML
6
+ from mapyta.style import PALETTES
6
7
  from mapyta.tiles import TileProviderKey
7
8
 
8
9
  __all__ = [
10
+ "PALETTES",
9
11
  "CircleStyle",
10
12
  "DrawConfig",
11
13
  "DrawTool",