@versatiles/svg-renderer 0.7.0 → 0.7.2
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.
- package/README.md +20 -10
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/maplibre.cjs +7 -7
- package/dist/maplibre.cjs.map +1 -1
- package/dist/maplibre.js +7 -7
- package/dist/maplibre.js.map +1 -1
- package/dist/maplibre.umd.js +7 -7
- package/dist/maplibre.umd.js.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -9556,12 +9556,12 @@ class SVGRenderer {
|
|
|
9556
9556
|
const [cx, cy] = roundXY(point.x + style.offset[0] * style.size, point.y + style.offset[1] * style.size);
|
|
9557
9557
|
elements.push(`<g transform="rotate(${String(style.rotate)},${formatNum(cx)},${formatNum(cy)})">` +
|
|
9558
9558
|
`<g transform="translate(${formatNum(iconXr)},${formatNum(iconYr)})${scaleStr}"${opacityAttr}${filterAttr}>` +
|
|
9559
|
-
`<use href="#${escapeXml(symDef.symbolId)}" />` +
|
|
9559
|
+
`<use xlink:href="#${escapeXml(symDef.symbolId)}" />` +
|
|
9560
9560
|
`</g></g>`);
|
|
9561
9561
|
}
|
|
9562
9562
|
else {
|
|
9563
9563
|
elements.push(`<g transform="translate(${formatNum(iconXr)},${formatNum(iconYr)})${scaleStr}"${opacityAttr}${filterAttr}>` +
|
|
9564
|
-
`<use href="#${escapeXml(symDef.symbolId)}" />` +
|
|
9564
|
+
`<use xlink:href="#${escapeXml(symDef.symbolId)}" />` +
|
|
9565
9565
|
`</g>`);
|
|
9566
9566
|
}
|
|
9567
9567
|
}
|
|
@@ -9594,7 +9594,7 @@ class SVGRenderer {
|
|
|
9594
9594
|
const pixelated = style.resampling === 'nearest';
|
|
9595
9595
|
for (const tile of tiles) {
|
|
9596
9596
|
const overlap = Math.min(tile.width, tile.height) / 10000; // slight overlap to prevent sub-pixel gaps between tiles
|
|
9597
|
-
let attrs = `x="${formatScaled(tile.x - overlap)}" y="${formatScaled(tile.y - overlap)}" width="${formatScaled(tile.width + overlap * 2)}" height="${formatScaled(tile.height + overlap * 2)}" href="${tile.dataUri}"`;
|
|
9597
|
+
let attrs = `x="${formatScaled(tile.x - overlap)}" y="${formatScaled(tile.y - overlap)}" width="${formatScaled(tile.width + overlap * 2)}" height="${formatScaled(tile.height + overlap * 2)}" xlink:href="${tile.dataUri}"`;
|
|
9598
9598
|
if (pixelated)
|
|
9599
9599
|
attrs += ' style="image-rendering:pixelated"';
|
|
9600
9600
|
this.#svg.push(`<image ${attrs} />`);
|
|
@@ -9607,19 +9607,19 @@ class SVGRenderer {
|
|
|
9607
9607
|
// Build defs content
|
|
9608
9608
|
const defsContent = [`<clipPath id="vb"><rect width="${w}" height="${h}"/></clipPath>`];
|
|
9609
9609
|
for (const sheet of this.#spriteSheetDefs.values()) {
|
|
9610
|
-
defsContent.push(`<image id="${escapeXml(sheet.defId)}" width="${formatNum(sheet.width)}" height="${formatNum(sheet.height)}" href="${escapeXml(sheet.href)}" />`);
|
|
9610
|
+
defsContent.push(`<image id="${escapeXml(sheet.defId)}" width="${formatNum(sheet.width)}" height="${formatNum(sheet.height)}" xlink:href="${escapeXml(sheet.href)}" />`);
|
|
9611
9611
|
}
|
|
9612
9612
|
for (const sym of this.#spriteSymbolDefs.values()) {
|
|
9613
9613
|
const clipId = `${sym.symbolId}-clip`;
|
|
9614
|
-
defsContent.push(`<clipPath id="${escapeXml(clipId)}"><rect width="${formatNum(sym.width)}" height="${formatNum(sym.height)}" /></clipPath>`, `<symbol id="${escapeXml(sym.symbolId)}"><g clip-path="url(#${escapeXml(clipId)})"><use href="#${escapeXml(sym.sheetDefId)}" x="${formatNum(-sym.x)}" y="${formatNum(-sym.y)}" /></g></symbol>`);
|
|
9614
|
+
defsContent.push(`<clipPath id="${escapeXml(clipId)}"><rect width="${formatNum(sym.width)}" height="${formatNum(sym.height)}" /></clipPath>`, `<symbol id="${escapeXml(sym.symbolId)}"><g clip-path="url(#${escapeXml(clipId)})"><use xlink:href="#${escapeXml(sym.sheetDefId)}" x="${formatNum(-sym.x)}" y="${formatNum(-sym.y)}" /></g></symbol>`);
|
|
9615
9615
|
}
|
|
9616
9616
|
for (const { content } of this.#sdfFilterDefs.values()) {
|
|
9617
9617
|
defsContent.push(content);
|
|
9618
9618
|
}
|
|
9619
9619
|
const parts = [
|
|
9620
|
-
`<svg viewBox="0 0 ${w} ${h}" width="${w}" height="${h}" xmlns="http://www.w3.org/2000/svg">`,
|
|
9620
|
+
`<svg viewBox="0 0 ${w} ${h}" width="${w}" height="${h}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`,
|
|
9621
9621
|
`<defs>\n ${defsContent.join('\n ')}\n</defs>`,
|
|
9622
|
-
`<g clip-path="url(#vb)">`,
|
|
9622
|
+
`<g id="map" clip-path="url(#vb)">`,
|
|
9623
9623
|
];
|
|
9624
9624
|
if (this.#backgroundColor.alpha > 0) {
|
|
9625
9625
|
parts.push(`<rect x="-1" y="-1" width="${(this.width + 2).toFixed(0)}" height="${(this.height + 2).toFixed(0)}" ${fillAttr(this.#backgroundColor)} />`);
|