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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@artsdatabanken/nbic-map-component

v0.3.0

Published

Shared map component built on OpenLayers

Downloads

243

Readme

nbic-map-component

Shared, framework-agnostic map component built on OpenLayers, designed to be used by host applications (Angular, React, Lit, plain TS/JS) through a stable API.

The library separates what the host application wants to do (MapApi) from how it is rendered (MapEngine / OpenLayers), making it easier to maintain, test, and extend.


Architecture

The architecture is intentionally layered:

Host app (Angular/React/Lit/vanilla)
   |
   |  calls methods + subscribes to events
   v
MapApi (public facade)
   |
   |  delegates 1:1 to an engine, keeps public types stable
   v
MapEngine (interface)
   |
   |  concrete implementation chosen at runtime (or build-time)
   v
OlMapEngine (OpenLayers implementation)
   |
   +--> LayerRegistry (indexes layers/sources)
   +--> Adapters (LayerDef -> OL layer, StyleDef -> OL style, SourceDef -> OL source)
   +--> Controllers (Draw / Hover / Select / Geo / Controls / Zoom)
   |
   v
OpenLayers (ol/Map, ol/layer, ol/source, ol/interaction, ol/style)

Design description

The host application (Angular, React, Lit, etc.):
	•	Owns application state
	•	Decides when and what to draw (layers, features, interactions)
	•	Talks only to MapApi

It never accesses OpenLayers directly.

MapApi
	•	Public API exposed by nbic-map-component
	•	Stable contract for host applications
	•	Methods like:
	•	adding/removing layers
	•	starting/stopping drawing
	•	selecting features
	•	controlling interactions

MapEngine
	•	Internal orchestration layer
	•	Translates MapApi calls into engine actions
	•	No OpenLayers imports
	•	Makes it possible to swap rendering engines in the future

OlMapEngine
	•	Concrete implementation using OpenLayers
	•	Owns:
	•	ol/Map
	•	layers, sources, interactions
	•	OpenLayers-specific logic (cluster, hover, select, draw)

Why this design?
	•	Clear separation of concerns
	•	Host apps stay simple and future-proof
	•	OpenLayers complexity is fully encapsulated
	•	Easier testing and playground setup

Internal structure

src/
├─ api/                 # Public types & events (no OpenLayers imports)
│  ├─ types.ts
│  ├─ events.ts
│
├─ core/
│  ├─ MapApi.ts         # Public facade
│  ├─ MapEngine.ts     # Internal engine interface
│
│  └─ ol/
│     ├─ OlMapEngine.ts
│     ├─ adapters/     # Layer / source / style adapters
│     ├─ interactions/ # Draw, Hover, Select controllers
│     ├─ layers/       # LayerRegistry, base-layer logic
│     ├─ utils/        # Geometry, extent, projection helpers
│
├─ presets/             # Predefined layers & sources (WMTS, base maps)
│
└─ index.ts             # Public entry point

🚀 Getting started

Install dependencies

npm install

Build the library

npm run build

Run tests

npm run test
npm run test:watch

Lint and format

npm run lint

🧪 Playground (local testing)

This repo includes a small Vite-powered playground to test the component in the browser.

Start it

npm run dev

📖 Usage

Install via npm (once published):

npm install nbic-map-component

Basic usage in Angular

import { NbicMapComponent, MapEvents } from 'nbic-map-component';
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';

export class AppComponent implements AfterViewInit {
  @ViewChild('mapEl', { static: true }) mapEl!: ElementRef<HTMLDivElement>;
  private map!: InstanceType<typeof NbicMapComponent>;

  ngAfterViewInit(): void {
    this.map = new NbicMapComponent({
          target: this.mapEl.nativeElement,
          projection: 'EPSG:3857',          // View must match WMTS projection
          center: [1157722.7042500454, 9208962.278247332],
          zoom: 4,
          minZoom: 1,
          maxZoom: 18,
          controls: { scaleLine: true, fullscreen: true, geolocation: true, zoom: true, attribution: true },
        });

    this.map.on(MapEvents.Ready, () => {
          this.mapReadyAction.next(true);
          this.map.activateHoverInfo();
        });
  }
}

html

<div #mapEl class="map"></div>

css

.map {
    height: 60vh;
    width: 100%;
}