mapyta 0.4.0__tar.gz → 0.4.2__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 (72) hide show
  1. {mapyta-0.4.0 → mapyta-0.4.2}/PKG-INFO +1 -1
  2. mapyta-0.4.2/docs/tutorial/configuration.md +129 -0
  3. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/config.py +11 -1
  4. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/map.py +23 -4
  5. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/markers.py +12 -3
  6. {mapyta-0.4.0 → mapyta-0.4.2}/pyproject.toml +1 -1
  7. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_map_creation.py +128 -0
  8. {mapyta-0.4.0 → mapyta-0.4.2}/uv.lock +1 -1
  9. mapyta-0.4.0/docs/tutorial/configuration.md +0 -93
  10. {mapyta-0.4.0 → mapyta-0.4.2}/.github/workflows/docs-preview.yml +0 -0
  11. {mapyta-0.4.0 → mapyta-0.4.2}/.github/workflows/docs.yml +0 -0
  12. {mapyta-0.4.0 → mapyta-0.4.2}/.github/workflows/lint.yml +0 -0
  13. {mapyta-0.4.0 → mapyta-0.4.2}/.github/workflows/publish.yml +0 -0
  14. {mapyta-0.4.0 → mapyta-0.4.2}/.github/workflows/tests.yml +0 -0
  15. {mapyta-0.4.0 → mapyta-0.4.2}/.gitignore +0 -0
  16. {mapyta-0.4.0 → mapyta-0.4.2}/.pre-commit-config.yaml +0 -0
  17. {mapyta-0.4.0 → mapyta-0.4.2}/.ruff.toml +0 -0
  18. {mapyta-0.4.0 → mapyta-0.4.2}/LICENSE +0 -0
  19. {mapyta-0.4.0 → mapyta-0.4.2}/README.md +0 -0
  20. {mapyta-0.4.0 → mapyta-0.4.2}/docs/.nav.yml +0 -0
  21. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/assets/images/favicon.ico +0 -0
  22. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/assets/images/logo-dark-mode.svg +0 -0
  23. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/assets/images/mapyta-logo-dark-mode.svg +0 -0
  24. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/assets/images/mapyta-logo-light-mode.svg +0 -0
  25. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/assets/javascripts/katex.js +0 -0
  26. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/assets/stylesheets/extra.css +0 -0
  27. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_overrides/main.html +0 -0
  28. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_scripts/__init__.py +0 -0
  29. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_scripts/generate_index.py +0 -0
  30. {mapyta-0.4.0 → mapyta-0.4.2}/docs/_scripts/generate_reference_pages.py +0 -0
  31. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/.nav.yml +0 -0
  32. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/advanced.md +0 -0
  33. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/animated.md +0 -0
  34. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/choropleth.md +0 -0
  35. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/clusters.md +0 -0
  36. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/coordinates.md +0 -0
  37. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/dataframe.md +0 -0
  38. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/drawing.md +0 -0
  39. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/export.md +0 -0
  40. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/faq.md +0 -0
  41. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/first-map.md +0 -0
  42. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/geodataframe.md +0 -0
  43. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/geometries.md +0 -0
  44. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/heatmaps.md +0 -0
  45. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/index.md +0 -0
  46. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/layers.md +0 -0
  47. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/markers.md +0 -0
  48. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/min-zoom.md +0 -0
  49. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/open-data.md +0 -0
  50. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/text-annotations.md +0 -0
  51. {mapyta-0.4.0 → mapyta-0.4.2}/docs/tutorial/tooltips-popups.md +0 -0
  52. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/__init__.py +0 -0
  53. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/coordinates.py +0 -0
  54. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/dataframe.py +0 -0
  55. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/export.py +0 -0
  56. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/geojson.py +0 -0
  57. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/markdown.py +0 -0
  58. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/style.py +0 -0
  59. {mapyta-0.4.0 → mapyta-0.4.2}/mapyta/tiles.py +0 -0
  60. {mapyta-0.4.0 → mapyta-0.4.2}/properdocs.yml +0 -0
  61. {mapyta-0.4.0 → mapyta-0.4.2}/tests/__init__.py +0 -0
  62. {mapyta-0.4.0 → mapyta-0.4.2}/tests/conftest.py +0 -0
  63. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_data.py +0 -0
  64. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_dataframe.py +0 -0
  65. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_draw.py +0 -0
  66. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_export.py +0 -0
  67. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_geometry.py +0 -0
  68. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_layers.py +0 -0
  69. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_map.py +0 -0
  70. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_markers.py +0 -0
  71. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_merge_and_chaining.py +0 -0
  72. {mapyta-0.4.0 → mapyta-0.4.2}/tests/test_utilities.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapyta
3
- Version: 0.4.0
3
+ Version: 0.4.2
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,129 @@
1
+ # Map Configuration
2
+
3
+ `MapConfig` controls the global look and feel: tile provider, zoom, dimensions, and optional plugins.
4
+
5
+ ```python exec="true" html="true" source="tabbed-right"
6
+ from shapely.geometry import Point
7
+ from mapyta import Map, MapConfig
8
+
9
+ config = MapConfig(
10
+ tile_layer="cartodb_dark",
11
+ zoom_start=14,
12
+ fullscreen=True,
13
+ minimap=True,
14
+ measure_control=True,
15
+ mouse_position=True,
16
+ )
17
+
18
+ m = Map(title="Dark Mode", config=config)
19
+ m.add_point(Point(5.1213, 52.0908), marker="🌃", tooltip="**Night Utrecht**")
20
+
21
+ m.to_html("dark_mode.html")
22
+
23
+ print(m.to_html()) # markdown-exec: hide
24
+ ```
25
+
26
+ ## MapConfig fields
27
+
28
+ | Field | Default | Description |
29
+ |-------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
30
+ | `tile_layer` | `"cartodb_positron"` | Tile provider key or list of keys |
31
+ | `zoom_start` | `12` | Initial zoom level |
32
+ | `min_zoom` | `0` | Prevent zooming out beyond this level |
33
+ | `max_zoom` | `19` | Prevent zooming in beyond this level |
34
+ | `max_native_zoom` | `None` | Highest zoom level the tile provider actually serves. Set this below `max_zoom` to upscale tiles instead of showing blank placeholders. |
35
+ | `attribution` | `None` | Custom tile attribution |
36
+ | `width` | `"100%"` | Map width |
37
+ | `height` | `"100%"` | Map height |
38
+ | `control_scale` | `True` | Show scale bar |
39
+ | `fullscreen` | `False` | Add fullscreen button |
40
+ | `minimap` | `False` | Add inset minimap |
41
+ | `measure_control` | `False` | Add distance/area measurement tool |
42
+ | `mouse_position` | `True` | Show cursor coordinates |
43
+
44
+ ## Available tile providers
45
+
46
+ | Key | Description |
47
+ |----------------------|---------------------------------------------|
48
+ | `openstreetmap` | Default OpenStreetMap |
49
+ | `cartodb_positron` | Light, minimal CartoDB (default) |
50
+ | `cartodb_dark` | Dark CartoDB |
51
+ | `cartodb_voyager` | CartoDB Voyager, colourful, detailed |
52
+ | `esri_satellite` | Esri satellite imagery |
53
+ | `esri_topo` | Esri topographic |
54
+ | `esri_streets` | Esri street map |
55
+ | `esri_gray` | Esri light gray canvas |
56
+ | `esri_ocean` | Esri ocean basemap |
57
+ | `opentopomap` | OpenTopoMap, topographic with contour lines |
58
+ | `stamen_terrain` | Stamen terrain with hillshading |
59
+ | `stamen_toner` | Stamen high-contrast B&W |
60
+ | `stamen_watercolor` | Stamen watercolor, artistic style |
61
+ | `stadia_alidade` | Stadia Alidade Smooth, clean, light |
62
+ | `stadia_dark` | Stadia Alidade Dark, modern dark theme |
63
+ | `kadaster_brt` | Dutch Kadaster topographic |
64
+ | `kadaster_luchtfoto` | Dutch Kadaster aerial photos |
65
+ | `kadaster_grijs` | Dutch Kadaster greyscale |
66
+
67
+ ## Zooming beyond native tile resolution
68
+
69
+ Every tile provider has a maximum zoom level at which it actually serves tiles. OpenStreetMap, for example, caps at zoom
70
+ 19. If `max_zoom` is set higher than that, Leaflet requests tiles that don't exist and renders blank gray placeholders
71
+ instead.
72
+
73
+ Setting `max_native_zoom` tells Leaflet the highest zoom at which real tiles are available. When the user zooms past
74
+ that level, Leaflet upscales the last available tile rather than showing a blank:
75
+
76
+ ```python exec="true" html="true" source="tabbed-right"
77
+ from shapely.geometry import Point
78
+ from mapyta import Map, MapConfig
79
+
80
+ m = Map(
81
+ center=(52.090, 5.121),
82
+ title="Zooming beyond native resolution",
83
+ config=MapConfig(
84
+ tile_layer="openstreetmap",
85
+ zoom_start=18,
86
+ max_zoom=21,
87
+ max_native_zoom=19,
88
+ ),
89
+ )
90
+ m.add_point(Point(5.1213, 52.0908), marker="📍", tooltip="**Dom Tower**")
91
+
92
+ m.to_html("max_native_zoom.html")
93
+ print(m.to_html()) # markdown-exec: hide
94
+ ```
95
+
96
+ Zoom in past level 19, the tiles blur slightly rather than going blank. `max_native_zoom` is only needed when you raise
97
+ `max_zoom` above the provider's native cap. With the default `max_zoom=19`, OpenStreetMap's tiles cover the full range
98
+ and no blanks appear. When `max_native_zoom` is left as `None`, `_create_base_map` passes `max_zoom` directly as the
99
+ native zoom limit, so Leaflet does not upscale, which is fine as long as `max_zoom` stays within what the provider
100
+ serves.
101
+
102
+ ## Multiple tile layers
103
+
104
+ Pass a list to `tile_layer` and add a layer control so users can switch between base maps:
105
+
106
+ ```python exec="true" html="true" source="tabbed-right"
107
+ from shapely.geometry import Point
108
+ from mapyta import Map, MapConfig
109
+
110
+ m = Map(
111
+ title="Multiple Tile Layers",
112
+ config=MapConfig(
113
+ tile_layer=["cartodb_positron", "cartodb_dark", "kadaster_brt"],
114
+ ),
115
+ )
116
+ m.add_point(Point(5.1213, 52.0908), marker="📍", tooltip="**Utrecht**")
117
+ m.add_layer_control(collapsed=False)
118
+
119
+ print(m.to_html()) # markdown-exec: hide
120
+ ```
121
+
122
+ The first layer in the list is shown by default. You can also add layers after construction with `add_tile_layer()`:
123
+
124
+ ```python
125
+ m = Map(title="Multiple Tile Layers")
126
+ m.add_tile_layer(name="esri_satellite")
127
+ m.add_tile_layer(name="cartodb_dark")
128
+ m.add_layer_control(collapsed=False)
129
+ ```
@@ -149,7 +149,16 @@ class MapConfig:
149
149
  Maximum zoom level, limiting how far users can zoom in. Higher
150
150
  values enable more detailed views, but effectiveness depends on
151
151
  the tile provider (e.g. OpenStreetMap maxes at 19). Exceeding
152
- the provider's limit may show blank tiles.
152
+ the provider's limit may show blank tiles unless
153
+ ``max_native_zoom`` is also set.
154
+ max_native_zoom : int | None
155
+ Highest zoom level at which the tile provider actually serves
156
+ tiles. When set below ``max_zoom``, Leaflet keeps the last
157
+ native-resolution tile visible (upscaled, so it blurs) instead
158
+ of rendering blank placeholders. ``None`` (default) means
159
+ Leaflet will request tiles at every zoom level up to
160
+ ``max_zoom``, which can produce blank or gray tiles if the
161
+ provider does not serve them.
153
162
  attribution : str | None
154
163
  Custom tile attribution.
155
164
  width : str | int
@@ -172,6 +181,7 @@ class MapConfig:
172
181
  zoom_start: int = 12
173
182
  min_zoom: int = 0
174
183
  max_zoom: int = 19
184
+ max_native_zoom: int | None = None
175
185
  attribution: str | None = None
176
186
  width: str | int = "100%"
177
187
  height: str | int = "100%"
@@ -123,6 +123,8 @@ class Map:
123
123
  layers = cfg.tile_layer if isinstance(cfg.tile_layer, list) else [cfg.tile_layer]
124
124
  multiple = len(layers) > 1
125
125
 
126
+ max_native_zoom = cfg.max_native_zoom if cfg.max_native_zoom is not None else cfg.max_zoom
127
+
126
128
  if multiple:
127
129
  # Multiple layers: create map without tiles, add all as TileLayer
128
130
  kwargs: dict[str, Any] = {
@@ -145,6 +147,8 @@ class Map:
145
147
  tiles=p["tiles"],
146
148
  name=p.get("name", layer_key),
147
149
  attr=p.get("attr"),
150
+ max_zoom=cfg.max_zoom,
151
+ max_native_zoom=max_native_zoom,
148
152
  show=i == 0,
149
153
  ).add_to(fmap)
150
154
  else:
@@ -152,20 +156,26 @@ class Map:
152
156
  tiles=layer_key,
153
157
  name=layer_key,
154
158
  attr=cfg.attribution,
159
+ max_zoom=cfg.max_zoom,
160
+ max_native_zoom=max_native_zoom,
155
161
  show=i == 0,
156
162
  ).add_to(fmap)
157
163
  else:
158
- # Single layer: pass directly to folium.Map (original behaviour)
164
+ # Single layer: build the map without tiles, then add a TileLayer
165
+ # explicitly so max_native_zoom can be set (folium.Map(tiles=...)
166
+ # does not expose it).
159
167
  provider = TILE_PROVIDERS.get(layers[0].lower())
160
168
  if provider:
161
169
  tiles = provider["tiles"]
162
170
  attr = provider.get("attr")
171
+ name = provider.get("name", layers[0])
163
172
  else:
164
173
  tiles = layers[0]
165
174
  attr = cfg.attribution
175
+ name = layers[0]
166
176
 
167
177
  kwargs: dict[str, Any] = {
168
- "tiles": tiles,
178
+ "tiles": None,
169
179
  "zoom_start": cfg.zoom_start,
170
180
  "min_zoom": cfg.min_zoom,
171
181
  "max_zoom": cfg.max_zoom,
@@ -175,9 +185,14 @@ class Map:
175
185
  }
176
186
  if self._center:
177
187
  kwargs["location"] = list(self._center)
178
- if attr:
179
- kwargs["attr"] = attr
180
188
  fmap = folium.Map(**kwargs)
189
+ folium.TileLayer(
190
+ tiles=tiles,
191
+ name=name,
192
+ attr=attr,
193
+ max_zoom=cfg.max_zoom,
194
+ max_native_zoom=max_native_zoom,
195
+ ).add_to(fmap)
181
196
 
182
197
  # Title overlay
183
198
  if self._title:
@@ -2073,6 +2088,8 @@ class Map:
2073
2088
  -------
2074
2089
  Map
2075
2090
  """
2091
+ cfg = self._config
2092
+ max_native_zoom = cfg.max_native_zoom if cfg.max_native_zoom is not None else cfg.max_zoom
2076
2093
  provider = TILE_PROVIDERS.get(name.lower())
2077
2094
  display_name = name
2078
2095
  if provider and tiles is None:
@@ -2084,6 +2101,8 @@ class Map:
2084
2101
  name=display_name,
2085
2102
  attr=attribution,
2086
2103
  overlay=overlay,
2104
+ max_zoom=cfg.max_zoom,
2105
+ max_native_zoom=max_native_zoom,
2087
2106
  ).add_to(self._map)
2088
2107
  return self
2089
2108
 
@@ -116,11 +116,20 @@ def build_icon_marker(
116
116
  icon_class = f"fa-solid {icon}"
117
117
  else:
118
118
  icon_class = f"glyphicon glyphicon-{icon}"
119
- icon_html = f'<div style="text-align:center;"><i class="{icon_class}" style="{style_str}"></i></div>{caption_suffix}'
119
+ fs = int(merged.get("font-size", "20px").replace("px", ""))
120
+ icon_html = (
121
+ f'<div style="text-align:center;line-height:1;height:{fs}px;">'
122
+ f'<i class="{icon_class}" style="{style_str};line-height:1;vertical-align:top;"></i>'
123
+ f"</div>"
124
+ f"{caption_suffix}"
125
+ )
126
+ h_icon = fs
127
+ w = max(fs, 100) if caption else fs
128
+ h = h_icon + (20 if caption else 0)
120
129
  return folium.DivIcon(
121
130
  html=icon_html,
122
- icon_size=(100, 50),
123
- icon_anchor=(50, 15),
131
+ icon_size=(w, h),
132
+ icon_anchor=(w // 2, h_icon // 2),
124
133
  )
125
134
 
126
135
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mapyta"
3
- version = "0.4.0"
3
+ version = "0.4.2"
4
4
  description = "Mapyta, open source python package for GIS mapping and visualization."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -376,3 +376,131 @@ class TestStyleDataclasses:
376
376
  # ===================================================================
377
377
  # Scenarios for the tile provider registry and tile layer management.
378
378
  # ===================================================================
379
+
380
+
381
+ def _tile_layers(fmap: folium.Map) -> list[folium.TileLayer]:
382
+ """Return all TileLayer children attached to a Folium map."""
383
+ return [child for child in fmap._children.values() if isinstance(child, folium.TileLayer)]
384
+
385
+
386
+ class TestTileLayerZoom:
387
+ """Regression scenarios for max_zoom / max_native_zoom wiring on TileLayers."""
388
+
389
+ def test_single_layer_defaults_native_zoom_to_max_zoom(self) -> None:
390
+ """
391
+ Scenario: Single tile layer with no explicit max_native_zoom.
392
+
393
+ Given: A MapConfig using defaults (max_zoom=19, max_native_zoom=None)
394
+ When: A Map is created
395
+ Then: The single TileLayer's options expose max_zoom=19 and
396
+ max_native_zoom=19 (native falls back to max_zoom)
397
+ """
398
+ # Act - When
399
+ m = Map()
400
+
401
+ # Assert - Then
402
+ layers = _tile_layers(m.folium_map)
403
+ assert len(layers) == 1, "Single-layer config should produce exactly one TileLayer"
404
+ opts = layers[0].options
405
+ assert opts["max_zoom"] == 19
406
+ assert opts["max_native_zoom"] == 19
407
+
408
+ def test_single_layer_respects_max_native_zoom(self) -> None:
409
+ """
410
+ Scenario: Single tile layer with max_native_zoom below max_zoom.
411
+
412
+ Given: A MapConfig with max_zoom=22 and max_native_zoom=19
413
+ When: A Map is created
414
+ Then: The TileLayer's options carry max_zoom=22 and
415
+ max_native_zoom=19 so Leaflet upscales instead of showing
416
+ gray placeholder tiles beyond zoom 19
417
+ """
418
+ # Arrange - Given
419
+ config = MapConfig(max_zoom=22, max_native_zoom=19)
420
+
421
+ # Act - When
422
+ m = Map(config=config)
423
+
424
+ # Assert - Then
425
+ layers = _tile_layers(m.folium_map)
426
+ assert len(layers) == 1
427
+ opts = layers[0].options
428
+ assert opts["max_zoom"] == 22
429
+ assert opts["max_native_zoom"] == 19
430
+
431
+ def test_multi_layer_propagates_max_native_zoom(self) -> None:
432
+ """
433
+ Scenario: Multiple tile layers all receive max_native_zoom.
434
+
435
+ Given: A MapConfig with two providers, max_zoom=22, max_native_zoom=19
436
+ When: A Map is created
437
+ Then: Every TileLayer exposes the same max_zoom/max_native_zoom
438
+ options (so toggling layers never regresses to gray tiles)
439
+ """
440
+ # Arrange - Given
441
+ config = MapConfig(
442
+ tile_layer=["openstreetmap", "cartodb_dark"],
443
+ max_zoom=22,
444
+ max_native_zoom=19,
445
+ )
446
+
447
+ # Act - When
448
+ m = Map(config=config)
449
+
450
+ # Assert - Then
451
+ layers = _tile_layers(m.folium_map)
452
+ assert len(layers) == 2, "Each listed provider should be added as a TileLayer"
453
+ for layer in layers:
454
+ assert layer.options["max_zoom"] == 22
455
+ assert layer.options["max_native_zoom"] == 19
456
+
457
+ def test_custom_tile_url_respects_max_native_zoom(self) -> None:
458
+ """
459
+ Scenario: Raw tile URL (not in TILE_PROVIDERS) with max_native_zoom.
460
+
461
+ Given: A MapConfig with a custom URL and max_native_zoom=19
462
+ When: A Map is created
463
+ Then: The TileLayer built from the custom URL still carries
464
+ max_zoom=22 and max_native_zoom=19
465
+ """
466
+ # Arrange - Given
467
+ config = MapConfig(
468
+ tile_layer="https://custom.tiles.example/{z}/{x}/{y}.png",
469
+ attribution="Custom Tiles © Example",
470
+ max_zoom=22,
471
+ max_native_zoom=19,
472
+ )
473
+
474
+ # Act - When
475
+ m = Map(config=config)
476
+
477
+ # Assert - Then
478
+ layers = _tile_layers(m.folium_map)
479
+ assert len(layers) == 1
480
+ opts = layers[0].options
481
+ assert opts["max_zoom"] == 22
482
+ assert opts["max_native_zoom"] == 19
483
+
484
+ def test_add_tile_layer_propagates_max_native_zoom(self) -> None:
485
+ """
486
+ Scenario: Layers added post-construction inherit the zoom config.
487
+
488
+ Given: A Map with max_zoom=22 and max_native_zoom=19
489
+ When: add_tile_layer is called with an additional provider
490
+ Then: The newly added TileLayer carries the same
491
+ max_zoom/max_native_zoom options as the base layer, so
492
+ toggling to it never regresses to blank tiles beyond zoom 19
493
+ """
494
+ # Arrange - Given
495
+ config = MapConfig(max_zoom=22, max_native_zoom=19)
496
+ m = Map(config=config)
497
+
498
+ # Act - When
499
+ m.add_tile_layer("cartodb_dark")
500
+
501
+ # Assert - Then
502
+ layers = _tile_layers(m.folium_map)
503
+ assert len(layers) == 2, "Base layer + added layer should both be present"
504
+ for layer in layers:
505
+ assert layer.options["max_zoom"] == 22
506
+ assert layer.options["max_native_zoom"] == 19
@@ -446,7 +446,7 @@ wheels = [
446
446
 
447
447
  [[package]]
448
448
  name = "mapyta"
449
- version = "0.3.0"
449
+ version = "0.4.1"
450
450
  source = { editable = "." }
451
451
  dependencies = [
452
452
  { name = "folium" },
@@ -1,93 +0,0 @@
1
- # Map Configuration
2
-
3
- `MapConfig` controls the global look and feel: tile provider, zoom, dimensions, and optional plugins.
4
-
5
- ```python exec="true" html="true" source="tabbed-right"
6
- from shapely.geometry import Point
7
- from mapyta import Map, MapConfig
8
-
9
- config = MapConfig(
10
- tile_layer="cartodb_dark",
11
- zoom_start=14,
12
- fullscreen=True,
13
- minimap=True,
14
- measure_control=True,
15
- mouse_position=True,
16
- )
17
-
18
- m = Map(title="Dark Mode", config=config)
19
- m.add_point(Point(5.1213, 52.0908), marker="🌃", tooltip="**Night Utrecht**")
20
-
21
- m.to_html("dark_mode.html")
22
-
23
- print(m.to_html()) # markdown-exec: hide
24
- ```
25
-
26
- ## MapConfig fields
27
-
28
- | Field | Default | Description |
29
- |-------|---------|-------------|
30
- | `tile_layer` | `"cartodb_positron"` | Tile provider key or list of keys |
31
- | `zoom_start` | `12` | Initial zoom level |
32
- | `min_zoom` | `0` | Prevent zooming out beyond this level |
33
- | `max_zoom` | `19` | Prevent zooming in beyond this level |
34
- | `attribution` | `None` | Custom tile attribution |
35
- | `width` | `"100%"` | Map width |
36
- | `height` | `"100%"` | Map height |
37
- | `control_scale` | `True` | Show scale bar |
38
- | `fullscreen` | `False` | Add fullscreen button |
39
- | `minimap` | `False` | Add inset minimap |
40
- | `measure_control` | `False` | Add distance/area measurement tool |
41
- | `mouse_position` | `True` | Show cursor coordinates |
42
-
43
- ## Available tile providers
44
-
45
- | Key | Description |
46
- |-----|-------------|
47
- | `openstreetmap` | Default OpenStreetMap |
48
- | `cartodb_positron` | Light, minimal CartoDB (default) |
49
- | `cartodb_dark` | Dark CartoDB |
50
- | `cartodb_voyager` | CartoDB Voyager, colourful, detailed |
51
- | `esri_satellite` | Esri satellite imagery |
52
- | `esri_topo` | Esri topographic |
53
- | `esri_streets` | Esri street map |
54
- | `esri_gray` | Esri light gray canvas |
55
- | `esri_ocean` | Esri ocean basemap |
56
- | `opentopomap` | OpenTopoMap, topographic with contour lines |
57
- | `stamen_terrain` | Stamen terrain with hillshading |
58
- | `stamen_toner` | Stamen high-contrast B&W |
59
- | `stamen_watercolor` | Stamen watercolor, artistic style |
60
- | `stadia_alidade` | Stadia Alidade Smooth, clean, light |
61
- | `stadia_dark` | Stadia Alidade Dark, modern dark theme |
62
- | `kadaster_brt` | Dutch Kadaster topographic |
63
- | `kadaster_luchtfoto` | Dutch Kadaster aerial photos |
64
- | `kadaster_grijs` | Dutch Kadaster greyscale |
65
-
66
- ## Multiple tile layers
67
-
68
- Pass a list to `tile_layer` and add a layer control so users can switch between base maps:
69
-
70
- ```python exec="true" html="true" source="tabbed-right"
71
- from shapely.geometry import Point
72
- from mapyta import Map, MapConfig
73
-
74
- m = Map(
75
- title="Multiple Tile Layers",
76
- config=MapConfig(
77
- tile_layer=["kartodb_positron", "cartodb_dark", "kadaster_brt"],
78
- ),
79
- )
80
- m.add_point(Point(5.1213, 52.0908), marker="📍", tooltip="**Utrecht**")
81
- m.add_layer_control(collapsed=False)
82
-
83
- print(m.to_html()) # markdown-exec: hide
84
- ```
85
-
86
- The first layer in the list is shown by default. You can also add layers after construction with `add_tile_layer()`:
87
-
88
- ```python
89
- m = Map(title="Multiple Tile Layers")
90
- m.add_tile_layer(name="esri_satellite")
91
- m.add_tile_layer(name="cartodb_dark")
92
- m.add_layer_control(collapsed=False)
93
- ```
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes