diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc9e497..0f401bfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - The sidebar can now be resized, both as a whole and in the split between the layer list and the layer editor - Allow viewing and changing the map's max zoom in the debug modal - Edit `text-variable-anchor-offset` as a list of anchors, each with an x and y offset; it previously showed no input +- Set the min and max zoom of a PMTiles source, for example to overzoom past the last zoom level in the file - _...Add new stuff here..._ ### 🐞 Bug fixes diff --git a/e2e/modals.spec.ts b/e2e/modals.spec.ts index 6643923f..bcae3365 100644 --- a/e2e/modals.spec.ts +++ b/e2e/modals.spec.ts @@ -178,6 +178,17 @@ describe("modals", () => { }); }); + test("add new pmtiles source with a max zoom", async () => { + await when.setValue("modal:sources.add.source_id", "pmtileszoom"); + await when.select("modal:sources.add.source_type", "pmtiles_vector"); + await when.setValue("modal:sources.add.maxzoom", "15"); + await when.click("modal:sources.add.add_source"); + await when.wait(200); + await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ + sources: { pmtileszoom: { type: "vector", maxzoom: 15 } }, + }); + }); + test("add new raster source", async () => { const sourceId = "rastertest"; await when.setValue("modal:sources.add.source_id", sourceId); diff --git a/src/components/modals/ModalSourcesTypeEditor.tsx b/src/components/modals/ModalSourcesTypeEditor.tsx index 7a08b815..c12f5088 100644 --- a/src/components/modals/ModalSourcesTypeEditor.tsx +++ b/src/components/modals/ModalSourcesTypeEditor.tsx @@ -287,6 +287,8 @@ class GeoJSONSourceFieldJsonEditor extends React.Component { url: url.startsWith("pmtiles://") ? url : `pmtiles://${url}` })} /> + {/* Left empty when unset, so the zoom range from the PMTiles header applies */} + this.props.onChange({ + ...this.props.source, + minzoom + })} + /> + this.props.onChange({ + ...this.props.source, + maxzoom + })} + /> {this.props.children} ; }