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

@india-boundary-corrector/openlayers-layer

v0.2.1

Published

OpenLayers TileLayer with India boundary corrections

Readme

@india-boundary-corrector/openlayers-layer

npm version

OpenLayers TileLayer extension that automatically applies India boundary corrections.

Try it on JSFiddle

Installation

npm install @india-boundary-corrector/openlayers-layer ol

Usage

Script Tag (IIFE) - Simplest Setup

No bundler required! Just include the script and use the global IndiaBoundaryCorrector:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/ol.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ol.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@india-boundary-corrector/openlayers-layer/dist/index.global.js"></script>

<div id="map" style="height: 400px;"></div>

<script>
  const { IndiaBoundaryCorrectedTileLayer } = IndiaBoundaryCorrector;

  const map = new ol.Map({
    target: 'map',
    layers: [
      new IndiaBoundaryCorrectedTileLayer({
        url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
        sourceOptions: {
          attributions: '© OpenStreetMap contributors'
        }
      })
    ],
    view: new ol.View({
      center: ol.proj.fromLonLat([75.3412, 33.2778]),
      zoom: 5
    })
  });
</script>

ES Modules

import { Map, View } from 'ol';
import { fromLonLat } from 'ol/proj';
import { IndiaBoundaryCorrectedTileLayer } from '@india-boundary-corrector/openlayers-layer';

const map = new Map({
  target: 'map',
  layers: [
    new IndiaBoundaryCorrectedTileLayer({
      url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png',
      sourceOptions: {
        attributions: '© OpenStreetMap contributors'
      }
    })
  ],
  view: new View({
    center: fromLonLat([75.3412, 33.2778]),
    zoom: 5
  })
});

With Explicit Layer Config

import { IndiaBoundaryCorrectedTileLayer } from '@india-boundary-corrector/openlayers-layer';

const layer = new IndiaBoundaryCorrectedTileLayer({
  url: 'https://{a-c}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png',
  layerConfig: 'cartodb-dark',
  sourceOptions: {
    attributions: '© CARTO © OpenStreetMap contributors'
  }
});

With Custom Layer Config

import { IndiaBoundaryCorrectedTileLayer, LayerConfig } from '@india-boundary-corrector/openlayers-layer';

const osmDeConfig = new LayerConfig({
  id: 'osm-de',
  tileUrlTemplates: ['https://tile.openstreetmap.de/{z}/{x}/{y}.png'],
  lineWidthStops: { 1: 0.5, 2: 0.6, 3: 0.7, 4: 1.0, 10: 3.75 },
  lineStyles: [
    // layerSuffix determines which PMTiles layer to use
    { color: 'rgb(180, 200, 180)', layerSuffix: 'osm' },
    { color: 'rgb(121, 146, 127)', layerSuffix: 'osm', widthFraction: 1/3, dashArray: [30, 2, 8, 2] },
  ],
});

const layer = new IndiaBoundaryCorrectedTileLayer({
  url: 'https://tile.openstreetmap.de/{z}/{x}/{y}.png',
  layerConfig: osmDeConfig,
  sourceOptions: {
    attributions: '© OpenStreetMap contributors'
  }
});

// Or use extraLayerConfigs for auto-detection
const layer2 = new IndiaBoundaryCorrectedTileLayer({
  url: 'https://tile.openstreetmap.de/{z}/{x}/{y}.png',
  extraLayerConfigs: [osmDeConfig],
  sourceOptions: {
    attributions: '© OpenStreetMap contributors'
  }
});

Factory Function

import { indiaBoundaryCorrectedTileLayer } from '@india-boundary-corrector/openlayers-layer';

const layer = indiaBoundaryCorrectedTileLayer({
  url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  sourceOptions: {
    attributions: '© OpenStreetMap contributors'
  }
});

Options

| Option | Type | Description | |--------|------|-------------| | url | string | Tile URL template with {z}, {x}, {y} placeholders | | pmtilesUrl | string | URL to PMTiles file (auto-detected if not provided) | | layerConfig | LayerConfig | string | Layer config object or config ID | | extraLayerConfigs | LayerConfig[] | Additional configs for auto-detection | | tileSize | number | Tile size in pixels for OpenLayers source (default: 256) | | fallbackOnCorrectionFailure | boolean | Return original tile if corrections fail (default: true) | | sourceOptions | Object | Additional options passed to XYZ source | | ...layerOptions | Object | Additional options passed to TileLayer |

Methods

| Method | Returns | Description | |--------|---------|-------------| | getTileFixer() | TileFixer | Get the underlying TileFixer instance | | getLayerConfig() | LayerConfig | Get the resolved layer configuration | | getRegistry() | LayerConfigRegistry | Get the layer config registry |

Events

correctionerror

Fired when the corrections data fails to load (e.g., PMTiles fetch failure). The tile will still display using the original uncorrected image.

layer.on('correctionerror', (e) => {
  console.warn('Corrections unavailable:', e.error);
  console.log('Tile coords:', e.coords); // { z, x, y }
  console.log('Tile URL:', e.tileUrl);
});

| Property | Type | Description | |----------|------|-------------| | error | Error | The error that occurred | | coords | object | Tile coordinates { z, x, y } | | tileUrl | string | URL of the tile being loaded |

Bundling

If you're bundling your application (Rollup, Webpack, Vite, etc.), you may need to copy the PMTiles data file to your output directory. See Bundling the PMTiles Asset for instructions.

License

Unlicense