aratcliffe / Leaflet.print

Plugin for printing a Leaflet map using either Mapfish or the GeoServer print module.
114 stars 40 forks source link

Printing an Area #25

Open fobetor opened 7 years ago

fobetor commented 7 years ago

Hello I would like to know, if it may be possible to tell this print module to print an area (I am using the Area Select plugin), not just the full map, but themap inside the area. It may be interesting (similar as what geoext does)

Thanks in advance Fernando

aratcliffe commented 7 years ago

Hi, sorry for the late reply. Mapfish uses the bbox parameter to specify the print area. By default the print provider calculates the print and scale parameters and sends those:

var jsonData = JSON.stringify(L.extend({
            units: L.print.Provider.UNITS,
            srs: L.print.Provider.SRS,
            layout: options.layout,
            dpi: options.dpi,
            outputFormat: options.outputFormat,
            outputFilename: options.outputFilename,
            layers: this._encodeLayers(this._map),
            pages: [{
                center: this._projectCoords(L.print.Provider.SRS, this._map.getCenter()),
                scale: this._getScale(),
                rotation: options.rotation
            }]
        }, this.options.customParams, options.customParams, this._makeLegends(this._map)))

You could try setting the bbox in the pages configuration through customParams.

fobetor commented 7 years ago

Thanks Adam Yes, you are rigth, I managed to pass the bbox to the print provider and it works fine. Thank you Fernando

fobetor commented 7 years ago

Hello again Adam Another question: Is there a way of changing the projection srs? I see it is defined as EPSG:3857 but if I change this and try touse the EPSG:27700 it throws an error? I cant find where it looks for the projexction definitions... Thank you

aratcliffe commented 7 years ago

It's referencing the property L.print.Provider.SRS. I would try setting that immediately after you load the library e.g.

<script>
L.print.Provider.SRS = 'EPSG:27700';
</script>
fobetor commented 7 years ago

Thanks ,i will try this