Skip to content

Commit

Permalink
Merge pull request #61 from andrewgryan/feature/zoom-offset
Browse files Browse the repository at this point in the history
add support for zoom-offset to l-tile-layer element
  • Loading branch information
andrewgryan authored Jan 2, 2025
2 parents e754bdb + 6561776 commit a8a2ec7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/l-tile-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ class LTileLayer extends LLayer {
});
const options = parse(schema, this);

const zoomOffset = this.getAttribute("zoom-offset");
if (zoomOffset) {
const number = parseInt(zoomOffset);
if (!isNaN(number)) {
options["zoomOffset"] = number;
}
}

// GridLayer options
const gridOptions = gridLayerOptions(this);

Expand Down
14 changes: 14 additions & 0 deletions src/l-tile-layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ it("should support tile-size attribute default value", () => {
const expected = tileLayer(urlTemplate, {});
expect(actual).toEqual(expected);
});

it.each([["-1", -1]])(
"should support zoom-offset attribute",
(text, zoomOffset) => {
const urlTemplate = "/";
const el = document.createElement("l-tile-layer");
el.setAttribute("url-template", urlTemplate);
el.setAttribute("zoom-offset", text);
document.body.appendChild(el);
const actual = el.layer;
const expected = tileLayer(urlTemplate, { zoomOffset });
expect(actual).toEqual(expected);
},
);

0 comments on commit a8a2ec7

Please sign in to comment.