Go to file
David Nguyen 46af2dd229
Remove dist, node_modules, and build artifacts from version control
This commit cleans up the repository by removing files that should be ignored according to .gitignore:
- Removed entire node_modules/ directory
- Removed dist and build artifacts (fesm2022/, lib/, index.d.ts)
- Removed IDE files (.idea/, .editorconfig)
- Removed .DS_Store files
- Removed .npmignore (not needed for source repo)

Kept .vscode/ files (extensions.json, launch.json, tasks.json) as they are explicitly allowed in .gitignore.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 16:02:08 -05:00
.vscode real initial commit 2025-10-27 13:39:29 -04:00
projects Add isPointInPolygon utility function for polygon containment checks 2025-11-04 11:16:08 -05:00
.gitignore real initial commit 2025-10-27 13:39:29 -04:00
angular.json real initial commit 2025-10-27 13:39:29 -04:00
package-lock.json Add custom icon support and routing functionality to map adapters 2025-10-30 23:01:58 -04:00
package.json Refactor map adapters for improved marker and routing management 2025-11-03 17:21:51 -05:00
public-api.d.ts initial commit 2025-09-04 13:47:54 -04:00
README.md real initial commit 2025-10-27 13:39:29 -04:00
tsconfig.json real initial commit 2025-10-27 13:39:29 -04:00
yarn.lock Refactor map adapters for improved marker and routing management 2025-11-03 17:21:51 -05:00

ngx-open-map-wrapper

An Angular 16+ library that provides a unified map component with automatic fallback between MapLibre GL (WebGL vector maps) and Leaflet (raster maps).

It automatically chooses the best renderer for the users device:

  • MapLibre GL if WebGL is supported
  • Leaflet if WebGL is not available or raster rendering is forced

Features

  • 🗺️ Always shows a map — automatically picks the right engine for the device
  • Uses MapLibre GL for modern devices with WebGL support
  • 🪶 Falls back to Leaflet for older or lowend devices
  • 🎯 Unified API for markers, zoom, and center — no need to learn two libraries
  • 📱 Works seamlessly across desktop and mobile
  • 🧩 Angularnative: standalone components, signals, and modern syntax

📦 Installation

Install the library and its peer dependencies:

yarn add ngx-open-open-map-wrapper leaflet maplibre-gl

Then import the required CSS styles in your global styles.css (or styles.scss):

@import "leaflet/dist/leaflet.css";
@import "maplibre-gl/dist/maplibre-gl.css";

🚀 Usage

Import the component

Since the library is standaloneready, you can import the component directly:

import { Component } from '@angular/core';
import { MapComponent, MapFacade } from 'ngx-open-open-map-wrapper';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [MapComponent],
  template: `
    <open-map
      [center]="[46.3385, -72.6106]"
      [zoom]="14"
      (mapReady)="onMapReady($event)"
    ></open-map>
  `,
})
export class AppComponent {
  private map?: MapFacade;

  onMapReady(facade: MapFacade) {
    this.map = facade;
    this.map.addMarker([46.3385, -72.6106], { color: 'blue' });
  }
}

⚙️ API

MapComponent Inputs

  • center: [lat, lng] → Initial map center
  • zoom: number → Initial zoom level
  • forceRaster: boolean → Force Leaflet raster mode even if WebGL is available
  • styleUrl: string → MapLibre style URL (default: MapLibre basic style)

MapComponent Outputs

  • (mapReady: MapFacade) → Emits the MapFacade instance once the map is initialized

MapFacade Methods

  • setCenter([lat, lng]) → Move the map center
  • setZoom(zoom: number) → Set zoom level
  • addMarker([lat, lng], { color?: string }) → Add a marker
  • destroy() → Clean up map instance

🧩 WebGL Detection Directive

You can also use the directive directly if you want to check WebGL support:

<div webglDetection (webglSupport)="onWebGLCheck($event)">
  @if (webglOk) {
    <my-component-using-webgl></my-component-using-webgl>
  } @else {
    <p>WebGL not supported → fallback</p>
  }
</div>
webglOk = false;

onWebGLCheck(supported: boolean) {
  this.webglOk = supported;
}

📜 License

MIT