ghybs / Leaflet.TileLayer.Fallback

Replaces missing Tiles by scaled lower zoom Tiles
Apache License 2.0
36 stars 18 forks source link

any idea how use with Angular 5 ? #9

Closed JarekSour closed 6 years ago

ghybs commented 6 years ago

Hi,

I guess this should be covered by TypeScript documentation: how to import a JavaScript library that does not have type definition yet.

Looking at other type definitions, you should be able to write a *.d.ts file with contents like:

import {TileLayer, TileLayerOptions} from 'leaflet';

declare module 'leaflet' {
  namespace tileLayer {
    function fallback(url: string, options?: TileLayerOptions): TileLayer;
  }
}

Reference this definition file in your TypeScript project configuration, then in your script you can import and use:

import * as L from 'leaflet';
import 'leaflet.tilelayer.fallback';

L.tileLayer.fallback(url, options);

For further help on how to use this library, especially in a configuration with some framework (e.g. Angular), please ask for help on Stack Overflow. You will reach a much wider audience there.