@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/dist/maplibre.js CHANGED
@@ -9737,12 +9737,12 @@ class SVGRenderer {
9737
9737
  const [cx, cy] = roundXY(point.x + style.offset[0] * style.size, point.y + style.offset[1] * style.size);
9738
9738
  elements.push(`<g transform="rotate(${String(style.rotate)},${formatNum(cx)},${formatNum(cy)})">` +
9739
9739
  `<g transform="translate(${formatNum(iconXr)},${formatNum(iconYr)})${scaleStr}"${opacityAttr}${filterAttr}>` +
9740
- `<use href="#${escapeXml(symDef.symbolId)}" />` +
9740
+ `<use xlink:href="#${escapeXml(symDef.symbolId)}" />` +
9741
9741
  `</g></g>`);
9742
9742
  }
9743
9743
  else {
9744
9744
  elements.push(`<g transform="translate(${formatNum(iconXr)},${formatNum(iconYr)})${scaleStr}"${opacityAttr}${filterAttr}>` +
9745
- `<use href="#${escapeXml(symDef.symbolId)}" />` +
9745
+ `<use xlink:href="#${escapeXml(symDef.symbolId)}" />` +
9746
9746
  `</g>`);
9747
9747
  }
9748
9748
  }
@@ -9775,7 +9775,7 @@ class SVGRenderer {
9775
9775
  const pixelated = style.resampling === 'nearest';
9776
9776
  for (const tile of tiles) {
9777
9777
  const overlap = Math.min(tile.width, tile.height) / 10000; // slight overlap to prevent sub-pixel gaps between tiles
9778
- 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}"`;
9778
+ 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}"`;
9779
9779
  if (pixelated)
9780
9780
  attrs += ' style="image-rendering:pixelated"';
9781
9781
  this.#svg.push(`<image ${attrs} />`);
@@ -9788,19 +9788,19 @@ class SVGRenderer {
9788
9788
  // Build defs content
9789
9789
  const defsContent = [`<clipPath id="vb"><rect width="${w}" height="${h}"/></clipPath>`];
9790
9790
  for (const sheet of this.#spriteSheetDefs.values()) {
9791
- defsContent.push(`<image id="${escapeXml(sheet.defId)}" width="${formatNum(sheet.width)}" height="${formatNum(sheet.height)}" href="${escapeXml(sheet.href)}" />`);
9791
+ defsContent.push(`<image id="${escapeXml(sheet.defId)}" width="${formatNum(sheet.width)}" height="${formatNum(sheet.height)}" xlink:href="${escapeXml(sheet.href)}" />`);
9792
9792
  }
9793
9793
  for (const sym of this.#spriteSymbolDefs.values()) {
9794
9794
  const clipId = `${sym.symbolId}-clip`;
9795
- 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>`);
9795
+ 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>`);
9796
9796
  }
9797
9797
  for (const { content } of this.#sdfFilterDefs.values()) {
9798
9798
  defsContent.push(content);
9799
9799
  }
9800
9800
  const parts = [
9801
- `<svg viewBox="0 0 ${w} ${h}" width="${w}" height="${h}" xmlns="http://www.w3.org/2000/svg">`,
9801
+ `<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">`,
9802
9802
  `<defs>\n ${defsContent.join('\n ')}\n</defs>`,
9803
- `<g clip-path="url(#vb)">`,
9803
+ `<g id="map" clip-path="url(#vb)">`,
9804
9804
  ];
9805
9805
  if (this.#backgroundColor.alpha > 0) {
9806
9806
  parts.push(`<rect x="-1" y="-1" width="${(this.width + 2).toFixed(0)}" height="${(this.height + 2).toFixed(0)}" ${fillAttr(this.#backgroundColor)} />`);