Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Image is broken when trying to nest within SVG tag

I'm using this example from the Deck.GL documentation

What I need is to nest an image within an SVG tag. Below is how I have built my SVG

function createSVGIcon(icon) {
  return `\
    <svg width="61" height="75" viewBox="0 0 61 75" xmlns="http://www.w3.org/2000/svg">
      <path d="M0 30.0412C2.26792e-05 56.6758 30.0379 74.8636 30.0379 74.8636C30.0379 74.8636 61 56.8367 61 30.0412C61 14.0981 46.8826 -0.251869 30.0379 0.00335371C13.4503 0.25468 -1.37723e-05 13.867 0 30.0412Z" fill="#2A6019"/>
      <svg viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg">
        <image href="${icon}" height="600" width="600" />
      </svg>
    </svg>
  `;
}

function svgToDataURL(svg) {
  return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
}

new IconLayer(
          this.getSubLayerProps({
            sizeScale: 11,
            data: singleTaskArray,
            id: "icon",
            getSize: () => 4,
            getPosition: (d) => d.geometry.coordinates,
            getFillColor: (d) => {
              switch (d.properties.priority) {
                case "1":
                  return [240, 72, 22];
                case "2":
                  return [250, 188, 56];
                default:
                  return [20, 98, 0];
              }
            },
            getIcon: (d) => ({
              width: 61,
              height: 75,
              mask: false,
              url: svgToDataURL(createSVGIcon(d.properties.type.icon)),
            }),
          })
        ),

When I load my map I can see the <path> which is a colored pin, however the <image> is showing as a broken link.

enter image description here

Any help on this would be much appreciated

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda