Jump to content

Hyperlinks within an SVG?

Recommended Posts

I'm working on a 7.1 site for a Chinese nonprofit and am attempting to create some kind of map that visitors can click on to learn about China's development projects in various parts of the world. Being dismayed at not being able to use an old-school HTML image map to accomplish this, I've settled on what I think could be a solution: SVG polygons on top of a map of the world.

Unfortunately, for this to work I need to be able to make each SVG image clickable. I've not found a way to make this work for more than just one SVG image. I've tried wrapping the "<a>" tag around the SVG "polygon" definition, wrapping the whole SVG definition with "<a href="..."> tags, but none of these work once I add then to more than one SVG image. To whit:

Quote
          <div name="South_America">
            <span class="tooltipText">South America</span>
            <svg width="360" height="250" style="stroke-width:3;stroke:yellow;">
                <a href="https://ctea.earth/South_America">
                  <polygon points="91,146,83,172,97,183,99,228,112,230,109,209,136,167,113,154" /></a>
            </svg>
        </div>

 

and

Quote

 

   <div name="South_America">
            <span class="tooltipText">South America</span>
            <a href="https://ctea.earth/South_America"><svg width="360" height="250" style="stroke-width:3;stroke:yellow;">
               <polygon points="91,146,83,172,97,183,99,228,112,230,109,209,136,167,113,154" />
            </svg></a>
        </div>

 

Edited by Pacoverde
Reformat second quote as code
Link to comment
  • Replies 1
  • Views 253
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.