bluehalo / ngx-leaflet-tutorial-plugins

MIT License
22 stars 10 forks source link

can't use new function "registerLayer" from "leaflet.brower.print" plugin #13

Closed Jonibigoud closed 5 years ago

Jonibigoud commented 6 years ago

Hi, when i try to use the function "registerLayer", i get this error:

TypeError: Cannot read property 'registerLayer' of undefined

Here is how to use this function:

L.Control.BrowserPrint.Utils.registerLayer(
    L.TileLayer.WMS,
    "L.TileLayer.WMS",
    function(layer, utils) {
        return L.tileLayer.wms(layer._url, layer.options);
    }
);

It seems that this function is not declared. Can we enhance the typescript declaration you propose so as to declare it?

import * as L from 'leaflet';
declare module 'leaflet' {
  namespace control {
    function browserPrint(options?: any): Control.BrowserPrint;
  }
  namespace Control {
    interface BrowserPrint {
      addTo(map: L.Map): any;
    }
  }
}

Thanks.

reblace commented 5 years ago

The error you're getting is that L.Control.BrowserPrint.Utils is undefined. It's more likely that the registerLayer function is located somewhere else in the API or it doesn't exist.