Skip to content

Commit

Permalink
Breaking Changes!! Adding a lot of more functions and separate Browse…
Browse files Browse the repository at this point in the history
…rPrint from the Control
  • Loading branch information
Falke-Design authored and Igor-Vladyka committed Feb 5, 2022
1 parent 2a5a61e commit 2378e6e
Show file tree
Hide file tree
Showing 16 changed files with 1,054 additions and 727 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## [2.0.0] - 2020-11-06
### !!Breaking Changes!!
The complete code has changed! It's now more readable and more structured.

Now it is possible to use BrowserPrint without a Control.

### Added
- `L.browserPrint(map, options)`
- More options added:
- `margin: {left: 10, top: 10, right: 10, bottom: 10`
- `enableZoom`
- `zoom`
- `rotate`
- `scale`
- `orientation`
- `.cancel()` to stop printing
- `browser-print-cancel` event added
- NPM Scripts: `npm run build` and `npm run watch`
### Changed
- Changed the namespace from `L.Control.BrowserPrint` to `L.BrowserPrint`
- Default modes have to called now like: `L.BrowserPrint.Mode.Custom(pageSize, options)`
- Replaced in the example Leaflet-Draw with [Leaflet-Geoman](https://github.com/geoman-io/leaflet-geoman), a more modern drawing plugin

## [1.0.7] - 2020-08-30

### Added
Expand Down
201 changes: 141 additions & 60 deletions README.md

Large diffs are not rendered by default.

47 changes: 40 additions & 7 deletions dist/leaflet.browser.print.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/leaflet.browser.print.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions examples/localization.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og=="
crossorigin=""></script>
<script src="../dist/leaflet.browser.print.min.js"></script>
<script src="../dist/leaflet.browser.print.js"></script>
<style>
html, body, #map { width: 100%; height: 100%; margin: 0px; padding: 0px;}
</style>
Expand Down Expand Up @@ -40,9 +40,11 @@
fillOpacity: 0.8
}).addTo(map);

L.control.browserPrint({
printModes: [L.control.browserPrint.mode.landscape(), L.control.browserPrint.mode.custom("Séléctionnez la zone")]
}).addTo(map);
var browserPrint = L.browserPrint(map);

var c = L.control.browserPrint({
printModes: [L.BrowserPrint.Mode.Landscape(), L.BrowserPrint.Mode.Custom("A4",{title: "Select area (Custom)"})]
},browserPrint).addTo(map);

</script>
</body>
Expand Down
6 changes: 5 additions & 1 deletion examples/manipulations.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
fillOpacity: 0.8
}).addTo(map);

L.control.browserPrint({
var c = L.control.browserPrint({
printLayer: L.tileLayer('//stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: 'abcd',
Expand All @@ -67,6 +67,10 @@
red.setStyle({fill: true});
});

map.on("browser-print-cancel", function(e) {
alert("Canceled");
});

</script>
</body>

Expand Down
8 changes: 4 additions & 4 deletions examples/savePNG.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
var map = L.map("map").setView([37.8, -96], 4);

// Here we hide all controls from end image
map.on(L.Control.BrowserPrint.Event.PrintStart, function() {
map.on(L.BrowserPrint.Event.PrintStart, function() {
map._controlCorners.topleft.style.display = "none";
map._controlCorners.topright.style.display = "none";
});

// Here we show all controls after image was created
map.on(L.Control.BrowserPrint.Event.PrintEnd, function() {
map.on(L.BrowserPrint.Event.PrintEnd, function() {
map._controlCorners.topleft.style.display = "";
map._controlCorners.topright.style.display = "";
});
Expand Down Expand Up @@ -184,11 +184,11 @@
L.control.browserPrint({
documentTitle: "printImage",
printModes: [
L.control.browserPrint.mode.auto("Download PNG")
L.BrowserPrint.Mode.Auto("Download PNG")
]
}).addTo(map);

map.on(L.Control.BrowserPrint.Event.PrintStart, function(e){
map.on(L.BrowserPrint.Event.PrintStart, function(e){
/*on print start we already have a print map and we can create new control and add it to the print map to be able to print custom information */
L.legendControl({position: 'bottomright'}).addTo(e.printMap);
});
Expand Down
Loading

0 comments on commit 2378e6e

Please sign in to comment.