This is about creating imagemaps that place clickable links on outlined portions of an image.
I put some very lengthy and explicit instructions on doing some of these things for people who do not necessarily ever plan on learning CSS and HTML, but want to do some things.
Old XBox Controller.json (451.6 KB)
Notes
- Imagemap and Buttons Scale Together
- Uses a PNG (Imported to Inkscape)
- Requires Application: Inkscape (Always Free)
- Easily Adapted to Tiddlywiki Links
Leaves more to be wanted
The capabilities are more limited than I would have liked.
- Cannot highlight map portions by clicking/hovering outside the image (General CSS Hover Issue. Browser compatibility.)
- Mapped highlights can ONLY do links. They cannot do additional actions, or use buttons. (as far as I have tried.)
Storing SVG Attributes in TiddlyWiki Fields
- This opens up a ton of possibilities for SVG mapping.
- SVG elements can be stored, added, subtracted, swapped using TiddlyWIki tiddlers, fields or dictionaries to store them.
- This might include other images, text, etc.
- Of course, they first need be created on the image in Inkscape first, for the size context.
YouTube Video: Responsive SVG Image Maps
Requires Inkscape Application
You have to install Inkscape application, which is an open source application that never costs money.
Start with a PNG Image
Even though this is an SVG method, you start with a typical PNG file.
Inkscape Instructions
YouTube Video: Responsive SVG Image Maps
This video is very clear about creating a very minimal and trimmed down SVG image for an image map.
The instructions are very rapid, and you might have to slow it down or pause it very frequently.
Exported SVG
The exported SVG will look something like this:
<svg version="1.1" viewBox="0 0 2578 431" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<image width="333" height="333" xlink:href="data:image/png;base64,iVBORw0KGgoA-------ElFTkSuQmCC" preserveAspectRatio="none"/>
<path d="m223.5 210.5c1.733 ---- 10.45z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
<path d="m413.2 135.1c7.006 ---- 2.599z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
<path d="m643.2 118.2c6.628 ---- 6.497z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
<path d="m871.9 142.9c6.227 ---- 2.599z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
</g>
</svg>
Adding Links
Surround the <path /> tags with Tiddlywiki <$link> widgets
<svg version="1.1" viewBox="0 0 2578 431" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<image width="333" height="333" xlink:href="data:image/png;base64,iVBORw0KGgoA-------ElFTkSuQmCC" preserveAspectRatio="none"/>
<$link to="Tiddler Title 1" >
<path d="m223.5 210.5c1.733 ---- 10.4 5." style="fill-opacity:6.582e-7;stroke-width:10.07"/>
</$link>
<$link to="Tiddler Title 2" >
<path d="m413.2 135.1c7.006 ---- 2.599z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
</$link>
<$link to="Tiddler Title 3" >
<path d="m643.2 118.2c6.628 ---- 6.497z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
</$link>
<$link to="Tiddler Title 4" >
<path d="m871.9 142.9c6.227 ---- 2.599z" style="fill-opacity:6.582e-7;stroke-width:10.07"/>
</$link>
</g>
</svg>
Store SVG Attributes in Fields
- Store the png image base64 in a field.
- Store map paths in individual fields
- Potentially swap map paths via fields
- Probably other applications
<svg version="1.1" viewBox="0 0 2578 431" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
{{!!bgimg}}
<$link to="Tiddler Title 1" >{{!!path1}}</$link>
<$link to="Tiddler Title 2" >{{!!path2}}</$link>
<$link to="Tiddler Title 3" >{{!!path3}}</$link>
<$link to="Tiddler Title 4" >{{!!path4}}</$link>
</g>
</svg
Moving CSS styles
<style>
path.pclass {
fill-opacity:6.582e-7
stroke-width:10.07
}
</style>
<svg version="1.1" viewBox="0 0 2578 431" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
{{!!bgimg}}
<path class="pclass" d="m223.5 210.5c1.733 ---- 10.45z" />
<path class="pclass" d="m413.2 135.1c7.006 ---- 2.599z" />
<path class="pclass" d="m643.2 118.2c6.628 ---- 6.497z" />
<path class="pclass" d="m871.9 142.9c6.227 ---- 2.599z" />
</g>
</svg>
Tooltips
Tooltips require placing <title></title> tags into the link by separating any single <path/> tags into multiple <path></path> tags.
Use the variable or field to store the pathās attribute instead of the whole path tag.
<path class="pclass" d={{!!pathfieldvar}} />
Add a closing </path> tag
<path class="pclass" d={{!!pathvarvar}} > </path>
Add a tooltip using <path> <title> </title> </path>
<path class="pclass" d={{!!pathfieldvar}} > <title> {{!!tooltipfieldvar}} </path>
Putting it All Together
<style>
path.pclass {
fill-opacity:6.582e-7
stroke-width:10.07
}
</style>
<svg version="1.1" viewBox="0 0 2578 431" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
{{!!bgimg}}
<path class="pclass" d={{!!path1}} > <title> {{!!tip1}} </title> </path>
<path class="pclass" d={{!!path2}} > <title> {{!!tip2}} </title> </path>
<path class="pclass" d={{!!path3}} > <title> {{!!tip3}} </title> </path>
<path class="pclass" d={{!!path4}} > <title> {{!!tip4}} </title> </path>
</g>
</svg>



