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

Print button outside the map #16

Closed habib-farhan closed 6 years ago

habib-farhan commented 6 years ago

I want to have the print button outside the map, so i appended that button on a div outside the map, but nothing happend when i click on the options. Any advice?

Igor-Vladyka commented 6 years ago

Please provide jsbin to debug your code, so I could help you.

Looks like some sort of event handling issue, or just something internally missing for appropriate plugin working functionality.

Or, you can just access everything from your own code. You can find active plugin object here:

map.printControl So you can call internal methods from it directly: Examples: map.printControl._printLandscape(); map.printControl._printPortrait(); map.printControl._printAutoI(); map.printControl._printCustom();

and it will start printing functionality from you click event handler.

Regards, Igor

scaddenp commented 5 years ago

Zombie issue, but how do you stop the icon appearing on the map?

Igor-Vladyka commented 5 years ago

.leaflet-control-browser-print { display: none; }

scaddenp commented 5 years ago

Excellent! thanks.

scaddenp commented 5 years ago

Actually, that sadly doesnt work. A style sheet specifying .leaflet-control-browser-print is created in the code and that always overrides what is put in the css.

scaddenp commented 5 years ago

I can "fix" by finding on DOM after adding control to map and either deleting or hiding it but that does feel clumsy. A config parameter to control whether icon added to leaflet control container would be cleaner.

scaddenp commented 5 years ago

Added a pull request for doing it.

Igor-Vladyka commented 5 years ago

You can just write it with !important, and that is it. .leaflet-control-browser-print { display: none!important; }

Anyway - in your PR you hide applying of default styles that needed for tool to work properly.

scaddenp commented 5 years ago

Whoops! tested wrongly (didnt clear cache). Anyway, not needed as the !important did the trick. Sorry for inconvenience, I have closed pull request. Just as side note, The pull didnt include dist because I couldnt figure out your build tool. I am extreme newbie at Github, but some guidance on that might help others submitting pull requests.

neerajlk commented 5 years ago

I want the print method to trigger after i pass page and orientation to it. how do i go about? what should i call in my printMyMap function given below?

var printMyMap = function (layout, orientation) { // my code here }

the above function will be called on click of a button. ANY help that i can get?