leaflet#GridLayer TypeScript Examples

The following examples show how to use leaflet#GridLayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: leaflet-tilelayer-subpixel-fix.ts    From aqualink-app with MIT License 6 votes vote down vote up
/*
 * Workaround for 1px lines appearing in some browsers due to fractional transforms
 * and resulting anti-aliasing.
 * https://github.com/Leaflet/Leaflet/issues/3575
 */

/* eslint-disable no-underscore-dangle */
(() => {
  if (!L || !L.GridLayer || !L.GridLayer.prototype) return;
  const gridLayerProto = L.GridLayer.prototype as GridLayer & {
    _initTile: (tile: HTMLImageElement) => void;
  };
  const originalInitTile = gridLayerProto._initTile;
  L.GridLayer.include({
    _initTile(tile: HTMLImageElement) {
      originalInitTile.call(this, tile);
      const tileSize = this.getTileSize();
      // eslint-disable-next-line no-param-reassign,fp/no-mutation
      tile.style.width = `${tileSize.x + 1}px`;
      // eslint-disable-next-line no-param-reassign,fp/no-mutation
      tile.style.height = `${tileSize.y + 1}px`;
    },
  });
})();