Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!