Igor-Vladyka / leaflet.browser.print

A leaflet plugin which allows users to print the map directly from the browser
https://igor-vladyka.github.io/leaflet.browser.print/
MIT License
155 stars 76 forks source link

Registering layer L.StripePattern in Browser print #77

Closed neerajlk closed 4 years ago

neerajlk commented 5 years ago

I have this issue in registering a pattern layer in browser-print,I tried adding the below code for registration in the library.

this.registerLayer(L.StripePattern, 'L.StripePattern', function (layer, utils) { return L.StripePattern(layer,utils.cloneOptions(layer.options)) });

However on print preview I am getting this error this.callInitHooks is not a function

the library for L.StripePattern is this leaflet.pattern.

Any help will be highly appreciated.

Igor-Vladyka commented 5 years ago

Hi,

You should use factory function, or new object for layer registration. Here is more details. So basically instead of return L.StripePattern(layer,utils.cloneOptions(layer.options)) just use factory function or add new in front of object creation. return L.stripePattern(layer,utils.cloneOptions(layer.options)) or return new L.StripePattern(layer,utils.cloneOptions(layer.options))