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

BrowserPrint with ShapeMarkers #70

Closed yemling closed 5 years ago

yemling commented 5 years ago

Your leaflet.browser.print is a great plugin. I just need a little help. I’m not sure how to register a renderer for L.ShapeMarker (https://github.com/rowanwins/Leaflet.SvgShapeMarkers). I’ve tried L.Control.BrowserPrint.Utils.registerRenderer(L.SVG, 'L.SVG'); and L.Control.BrowserPrint.Utils.registerRenderer(L.ShapeMarker’ 'L.ShapeMarker'); (using different capitalisation variations) And I’ve added both… And it’s not working. Should the registerRenderer be added before or after the BrowserPrint is added to the map? Please can you advise? Thanks in advance.

Igor-Vladyka commented 5 years ago

Hi, It's quite easy. And you need to add this code before first print (so it's actually in any place of your code near map creation logic). So we adding first arg to compare for typeof, second to get for event as marker and last one to actually recreate marker. L.Control.BrowserPrint.Utils.registerLayer( L.ShapeMarker, "L.ShapeMarker", function(layer, utils) { return L.shapeMarker(layer.getLatLng(), utils.cloneOptions(layer.options)); } );

yemling commented 5 years ago

thank you!

luispina commented 5 years ago

TE AMO!