Skip to content

Commit

Permalink
Merge pull request #59 from sblaauw/fix-programmatic-print
Browse files Browse the repository at this point in the history
Fix programmatic print
  • Loading branch information
rowanwins authored Jan 11, 2018
2 parents 5f3fc8c + 32612ef commit 75b3193
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A simple [leaflet](http://www.leafletjs.com) plugin which adds an icon to print or export a map.

## Features
* Supports resizing to prefined sizes (A4 Landscape & Portait) as well as custom sizes
* Supports resizing to predefined sizes (A4 Landscape & Portrait) as well as custom sizes
* Supports saving to png, as well as printing
* Compatible with both Leaflet v1+ and 0.7
* Tested on Chrome, Firefox
Expand All @@ -29,7 +29,7 @@ You can pass a number of options to the plugin to control various settings.
| tileLayer | [Leaflet tile layer](http://leafletjs.com/reference-1.1.0.html#tilelayer) | `null` | A tile layer that you can wait for to draw (helpful when resizing) |
| tileWait | Integer | 500 | How long to wait for the tiles to draw (helpful when resizing) |
| filename | string | 'map' | Name of the file if export only option set to true |
| hidden | Boolean | false | Set to true if you don't want to display the toolbar. Instead you can create your own buttons or fire print events programtically. You still need to call `addTo(map)` to set the leaflet map context. |
| hidden | Boolean | false | Set to true if you don't want to display the toolbar. Instead you can create your own buttons or fire print events programmatically. You still need to call `addTo(map)` to set the leaflet map context. |
| hideControlContainer | Boolean | true | Hides the leaflet controls like the zoom buttons and the attribution on the print out. |
| hideClasses | array | [] | Hides classes on the print out. Use an array of strings as follow : ['div1', 'div2'] |
| customWindowTitle | string | Defaults to title of map window. | A title for the print window which will get added the printed paper. |
Expand All @@ -49,13 +49,13 @@ L.easyPrint({
### Methods / Using programmatically
| Method | Options | Description |
| --------------|--------------|--------------|
| printMap(size, filename) | Print size name, either 'CurrentSize', 'A4Portait', 'A4Landscape', or the `className` of a custom size. And a filename | Manually trigger a print operation |
| printMap(size, filename) | Print size name, either 'CurrentSize', 'A4Portrait', 'A4Landscape', or the `className` of a custom size. And a filename | Manually trigger a print operation |
````
var printPlugin = L.easyPrint({
hidden: true,
sizeModes: ['A4Portrait']
}).addTo(map);
printPlugin.printMap('A4Portait', 'MyFileName');
printPlugin.printMap('A4Portrait', 'MyFileName');
````


Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ L.Control.EasyPrint = L.Control.extend({
_resizeAndPrintMap: function (sizeMode) {
this.outerContainer.style.opacity = 0;
var pageSize = this.options.sizeModes.filter(function (item) {
return item.className === sizeMode
return item.className.indexOf(sizeMode) > -1;
});
pageSize = pageSize[0]
this.mapContainer.style.width = pageSize.width + 'px';
Expand Down

0 comments on commit 75b3193

Please sign in to comment.