I already have an in depth thread about how the image-map appearance for selects works / errors in Collect & Enketo, but this is a more approachable guide to creating & using them plus an example form & SVGs.
Huge thanks to @Thalie for supplying some of the source SVGs - apologies it took me forever to get this demo together! All images have CC attribution within the form.
Showcase highlights;
- You don't need nice vector art to use image-map, an existing raster image/diagram or a simple sketch will work just as well, as you can embed a raster image within an SVG as the bottom layer, and then place partially opaque elements on top that are the choices. This avoids the need to convert or create vector artwork and can still result in very compact files.
- With aggressive lossless PNG compression these files can be quite small - a 500kb vector PDF became a 47kb SVG (example 1) and a 2.1mb raster-vector SVG became a 58kb SVG (example 3). Even a many colour JPG illustration was only 227kb in SVG form (example 2).
- Complicated vector PDFs can be vectorised but result in extremely large files (10-20mb in some cases), so an embedded raster of sufficiently high resolution is almost always 1-10% of the size and still legible when zoomed.
image-mapcan be used as a user guide ("Go to this location"), not only an input ("Where did you go?") - if previous inputs / lookups return choice values, these can be calculated into aread_onlyselect, and the focus item(s) will appear selected.
General tips when creating SVGs;
- When using vector art, if you are not using elements of the drawing as choices, it is best to place a partially opaque element beneath the drawing content that is to be the select. This works best for line drawings with text / fine art that is otherwise difficult to select due to the fine target size, refer the diagram in the first example.
- When using raster art, the elements must be placed above it to be visible and selectable, and need to be partially opaque so as not to totally obscure the drawing below. Refer the map in the second example.
- If the elements are filled orange or blue they will be difficult to see when they are selected in Collect or Enketo, respectively. Refer the 'Rarement' option in the fourth example in Collect.
- To make items more visible when selected in Enketo, set stroke paint to 'undefined' and stroke style width to a large value, then the wide outline will appear only when selected. (all examples)
- Shapes or paths must have fill as otherwise only the outine is selectable. This fill can have a very low opacity value so it doesn't appear, refer the circle below 'Rarement' in the third example.
- Groups of non contiguous elements can be selected if the group has the choice value. Refer the lakes in the second example.
- If possible, convert any items used as choices to paths. Collect can select paths, objects & groups. Enketo can generally only select paths, but sometimes also groups (see the Lakes in the map
and C014 in the diagram
) and in this example, one object does work (see the 'Rarement' ellipse in third example
) while others don't (see the yellow element and C008-C015 in the first example
) - If possible, create artwork with an aspect ratio that matches your device orientation, and scale the canvas to match, otherwise it will have a lot of white space or require scrolling even when zoomed out in Collect
- Play with PNG encoding parameters, by reducing bit depth, colour type etc and testing different filter/deflate options file size can be drastically reduced with no quality loss. Much more here.
Form:
SVG_showcase.xlsx (86.3 KB)
Images:
images.zip (245.8 KB)



