Skip to content

Properties

WARNING

vue-img-mapper is currently in beta. Features and APIs are still evolving and improvements are coming soon.

Together, below sections let you fully control the component, customize its behavior and appearance, handle user interactions, configure individual areas, and access internal function references via Vue refs.

Component Properties

Configure the main behavior, appearance, and responsiveness of the component.

PropTypeDescriptionDefault
srcstringImage URL to displayrequired
namestringUnique map name associated with the imagerequired
areasarrayArray of area objects (see Area Properties)required
areaKeyNamestringKey used to uniquely identify areasid
isMultiboolAllows multiple areas to be selectedtrue
toggleboolEnables toggling selection on clickfalse
activeboolEnables area listeners and highlightingtrue
disabledboolDisables highlighting and interactionsfalse
fillColorstringHighlight fill colorrgba(255, 255, 255, 0.5)
strokeColorstringHighlight border colorrgba(0, 0, 0, 0.5)
lineWidthnumberBorder thickness of highlighted zones1
imgWidthnumberOriginal width of the image0
widthnumber | (func => number)Image width (can be use as a function for dynamic sizing)0
heightnumber | (func => number)Image height (can be use as a function for dynamic sizing)0
naturalboolUse the image's original dimensionsfalse
responsiveboolEnable responsive scaling (requires parentWidth)false
parentWidthnumberMax width of parent container0
containerPropsobjectProps for the wrapping <div>null
imgPropsobjectProps for the <img> elementnull
canvasPropsobjectProps for the <canvas> elementnull
mapPropsobjectProps for the <map> elementnull
areaPropsobject | arrayProps for <area> elementsnull

Callbacks

Handle user interactions, such as clicks, hovers, and touch events on the mapped areas or image.

CallbackTriggerSignature
@changeClick on an area(selectedArea, areas) => void
@imageClickClick outside mapped areas(event) => void
@imageMouseMoveMouse move over the image(event) => void
@clickClick on a mapped area(area, index, event) => void
@mousedownMouse down on area(area, index, event) => void
@mouseupMouse up on area(area, index, event) => void
@touchstartTouch start on area(area, index, event) => void
@touchendTouch end on area(area, index, event) => void
@mousemoveMouse move over area(area, index, event) => void
@mouseenterHover over area(area, index, event) => void
@mouseleaveLeave area(area, index, event) => void
@loadImage loaded & canvas initialized(event, dimensions) => void

Methods

Retrieve internal function references through Vue refs for advanced control.

MethodDescription
getRefsReturns refs for the container, canvas, and image elements

Area Properties

Define individual area shapes, coordinates, styling, and interaction behavior within the image map.

PropertyTypeDescriptionDefault
idstringUnique identifier; defaults to index if not provided. This can be customized using the areaKeyName property.based on areaKeyName
shapestringShape: rect, circle, polyrequired
coordsstring[]Coordinates for the area:
  • rect: top-left-X, top-left-Y, bottom-right-X, bottom-right-Y
  • circle: center-X, center-Y, radius
  • poly: List of points defining the polygon as point-X, point-Y, ...
required
activeboolEnables area listeners and highlightingtrue
disabledboolDisables highlighting and interactionsfalse
hrefstringTarget link for area clicks, ignored if onClick existsundefined
fillColorstringHighlight fill colorrgba(255, 255, 255, 0.5)
strokeColorstringHighlight border colorrgba(0, 0, 0, 0.5)
lineWidthnumberBorder thickness of highlighted zones1
preFillColorstringPre-filled highlight colorundefined

Additional properties available when triggered via an event:

PropertyTypeDescription
scaledCoordsnumber[]Coordinates adjusted to current image size
centernumber[]Centroid coordinates [X, Y] of the area

Released under the MIT License.