npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

angular-image-mapper-component

v0.0.4-ng15

Published

An Angular library with the `ImageMapperComponent` for displaying and interacting with clickable regions on images (e.g., clickable maps).

Downloads

91

Readme

angular-image-mapper

An Angular library with the ImageMapperComponent for displaying and interacting with clickable regions on images (e.g., clickable maps).


Installation

Install the library (if published on npm):

npm install angular-image-mapper-component

If locally:

  1. Build the library with:
ng build angular-image-mapper-component
  1. Add a path to tsconfig.json in the paths section pointing to dist/angular-image-mapper-component.

Usage

Import the component and types into your Angular module:

import { ImageMapperComponent, Area, Colors } from 'angular-image-mapper-component';

@NgModule({
  declarations: [ ... ],
  imports: [
    ...,
    ImageMapperComponent,
  ],
})
export class AppModule {}

ImageMapperComponent

This component renders an image with interactive regions.

Input Parameters (inputs)

| Name | Required | Type | Description | |--------------|----------|----------------|--------------------------------------------------------------------------| | src | Yes | string | Image URL | | width | Yes | number | Image width | | height | No | number | Image height (optional) | | imgWidth | No | number | Actual source image width (for scaling coordinates) | | areas | Yes | Array<Area> | Array of regions to display | | colors | Yes | Colors | Colors for region states | | selected | No | Array<Area> | Regions selected by click | | preselected| No | Array<Area> | Regions preselected by default |


Output Events (outputs)

| Name | Required | Description | |------------------|----------|-------------------------------------------------| | onClick | No | Triggered on region click | | onMouseEnter | No | Mouse entering a region | | onMouseLeave | No | Mouse leaving a region | | onMouseMove | No | Mouse moving over a region | | onImageClick | No | Click on the image outside any region | | onImageMouseMove| No | Mouse moving over the image outside any region | | onLoad | No | Image loaded and ready |


Types

Area

export interface AreaBase {
  _id: string;
  name: string;
  coords: number[];
  shape?: string;
}

export type Area<T = {}> = AreaBase & T;
  • coords is an array of numbers; coordinate format depends on shape.
  • shape is shape type: 'circle', 'poly', 'rect'.

Colors

export interface Colors {
  defaultColor: string; // Default color
  hoverColor: string; // Hover color
  clickColor: string; // Click color
  activeColor: string; // Color for 'preselected' array
}

Usage Example

*module.ts

import { AppComponent } from './app.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ImageMapperComponent, ImageMapperHelperAreaComponent } from 'angular-image-mapper-component';
import { BrowserModule } from '@angular/platform-browser';

@NgModule({
  declarations: [AppComponent],
  imports: [
    CommonModule,
    BrowserModule,
    ImageMapperComponent,
    ImageMapperHelperAreaComponent
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

*component.ts

import { Component } from '@angular/core';

// src
import { areas, colors } from '../constants';
import { Area } from 'angular-image-mapper-component';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent {
  protected readonly areas = areas;
  protected readonly colors = colors;

  public imgUrl = 'body_front.svg';
  public selected: Array<Area> = []
  public preselected: Array<Area> = []

  onFocusArea (event: any): void {
    const areaIndex = this.selected.findIndex((area) => area._id === event.area._id)
    this.selected = areaIndex >= 0
      ? this.selected.filter((area) => area._id !== event.area._id)
      : this.selected.concat(event.area)
  }
}

*component.html

<app-image-mapper
  name="body-map"
  [src]="imgUrl"
  [areas]="areas"
  [colors]="colors"
  [width]="655"
  [selected]="selected"
  [preselected]="preselected"
  (onClick)="onFocusArea($event)"
 />

ImageMapperHelperComponent

A helper component designed to display the same image as the main ImageMapperComponent but allows users to draw shapes interactively by simple clicks on the image and immediately obtain their coordinates.

Usage

<app-image-mapper-helper-area
  name="body-map-helper"
  [src]="imgUrl"
  [width]="655"
/>

Thanks! @hardliner_s