Skip to content

Demos

The demonstrations on this page show how to use some of ImageMapster’s features. The first, USA Map, is an interactive demo that lets you change many options interactively to see how they affect the image map. The other demos are far simpler and show how to use specific features. The Skeleton Joints demo is a project contributed by a user from a private web site.

See live examples for a comprehensive set of examples from the ImageMapster repositoryExternal link leaves this site and JSFiddleExternal link leaves this site, all with complete source code.

USA Map

To manipulate all the options interactively, go to the USA map demoExternal link leaves this site.

The basic version shown here demonstrates a few options:

  • altImage allows a different image to be used for both the highlight and select effects
  • staticState - Washington is set to false which prevents it from being selected
  • isSelectable - Oregon is set to false which prevents it from being selected
  • selected - Texas and Maine are set to true meaning they will be automatically selected upon initialization

See this demo in a JSFiddleExternal link leaves this site

Vegetable Tray
Click a vegetable to see it's description!

Simple example demonstrating singleSelect which allows only one area to be selected, and changing a tooltip on the fly. The dip has a tooltip, which is different if asparagus is selected. This also shows how to use area-specific options to control the styling of each area individually. Some areas use different colors for selection to ensure that the highlight is visible even though each area is a substantially different color.

See this demo in a JSFiddleExternal link leaves this site

Frog Menu

This example shows how to use ImageMapster to create menus. The image was taken from a CSS tutorialExternal link leaves this site showing how to use CSS to create menus. The example uses ImageMapster instead to create a more interesting menu with almost no code. The example uses includeKeys to highlight areas other than the one which is activated, and altImage to render the highlight with an alternate image (instead of just filling). The vertical space above each menu will also activate the menu, but won’t itself highlight.

See this demo in a JSFiddleExternal link leaves this site

Beatles Menu
Hover over a band member to learn more about them!

This example shows how to activate areas from code, and change options on the fly using the set_options method. The isSelectable option has been disabled to prevent selection of areas - only mouseover highlighting is in effect. Finally, it uses the onMouseover and onMouseout events to show captions for each area.

This example also uses multiple groups assigned to each area to activate all areas easily. Each area has two keys: the primary one which is unique, and another which is the same for each area — “all”. The “all” key is used to activate all the areas at once when the mouse enters the image.

This example, like the frog menu, mimics a CSS3 example: Stu Nicholls’ creating an image map using CSS onlyExternal link leaves this site article.

See this demo in a JSFiddleExternal link leaves this site

Shapes Hotspots

The Shapes demo shows how to create hotspots within other hotspots. It also uses includeKeys like the Frog demo to activate areas from other areas, but slightly differently; the target area isn’t itself a hotspot. Finally, it uses isMask to exclude a small area from the outer ring of the circle. When using masks to exclude areas within other areas, the stroke option will also render a border around the interior perimeter of the outer area.

In the code, you will notice that the inner circle area is included in two groups: inner-circle and inner-circle-mask. This makes it possible to use the inner circle as a mask for the outer circle, so it is excluded when the outer ring is highlighted, as well as its own hotspot, without duplicating the area data.

With Internet Explorer 6-8, using VML, masking cannot be done natively. In this case the effect is simulated by rendering the masked area with a specific color that can be defined with the fillColorMask option. This option is ignored when using HTML5 canvases. The default is white, which is used for the inner circle, and 2nd small circle in the ring is set specifically to match the color of the ring area.

See this demo in a JSFiddleExternal link leaves this site

Gelderland Map

This example shows how to manually resize maps dynamically with the resize method. Resizing an active mapster-bound image map will retain all current state data. With VML (IE < 8), the actual selection data can’t be resized dynamically, so it will be redrawn after the operation finishes. By using images that have a larger native size than the initial display size, resizing can be used to zoom and enhance detail.

You can also configure ImageMapster to automatically resize images (e.g., when the browser window resizes) via the autoResize option in order to avoid having to manually handle resizing.

During a resize (manual or auto), ImageMapster can adjust the image map of any image loaded to its effective size. That is, if you have an image map that doesn’t match the size you need to use in an application, you can just set the CSS or height/width properties for an image to whatever you need, and ImageMapster will automatically adjust the area data in the image map. Automatic scaling is the default behavior, however if you do not want this functionality, it can be disabled by setting scaleMap option.

At this time, scaling during a resize only works when the aspect ratio is maintained. While it won’t stop you from changing the size to different proportions from its natural ones, the results will be unpredictable.

See this demo in a JSFiddleExternal link leaves this site

Skeleton Joints

The Skeleton Joint demoExternal link leaves this site is a user-contributed example of using ImageMapster to allow synchronizing selections from a complex list with an image. It is from a private web site, but the author has granted permission to use it here.