Class: PrintUtils service:ngeoPrintUtils

ngeo.PrintUtils

new PrintUtils()

Provides a service with print utility functions.

Methods

createPrintMaskPostcompose(getSize, getScale, opt_rotation)

Return a function to use as map postcompose listener for drawing a print mask on the map.

Parameters:
Name Type Description
getSize function():ol.Size

User-defined function returning the size in dots of the map to print.

getScale function(olx.FrameState):number

User-defined function returning the scale of the map to print.

opt_rotation function():number=

User defined function returning the inclination of the canvas in degree (-180 to 180). returning the scale of the map to print.

Returns:
function(ol.render.Event)

Function to use as a map postcompose listener.

getBottomLeftCorner(mapCenter)

Get the coordinates of the bottom left corner of the printed map.

Parameters:
Name Type Description
mapCenter ol.Coordinate

Center of the map to print.

Returns:
ol.Coordinate

The coordinates of the bottom left corner.

getBottomRightCorner(mapCenter)

Get the coordinates of the bottom rigth corner of the printed map.

Parameters:
Name Type Description
mapCenter ol.Coordinate

Center of the map to print.รง

Returns:
ol.Coordinate

The coordinates of the bottom rigth corner.

getOptimalResolution(mapSize, printMapSize, printMapScale)

Get the optimal map resolution for a print scale and a map size.

Parameters:
Name Type Description
mapSize ol.Size

Size of the map on the screen (px).

printMapSize ol.Size

Size of the map on the paper (dots).

printMapScale number

Map scale on the paper.

Returns:
number

The optimal map resolution.

getOptimalScale(mapSize, mapResolution, printMapSize, printMapScales)

Get the optimal print scale for a map, the map being defined by its size (in pixels) and resolution (in map units per pixel).

Parameters:
Name Type Description
mapSize ol.Size

Size of the map on the screen (px).

mapResolution number

Resolution of the map on the screen.

printMapSize ol.Size

Size of the map on the paper (dots).

printMapScales Array.

Supported map scales on the paper. The scales are provided as scale denominators, sorted in ascending order. E.g. [500, 1000, 2000, 4000].

Returns:
number

The best scale. -1 is returned if there is no optimal scale, that is the optimal scale is lower than or equal to the first value in printMapScales.

getUpLeftCorner(mapCenter)

Get the coordinates of the up left corner of the printed map.

Parameters:
Name Type Description
mapCenter ol.Coordinate

Center of the map to print.

Returns:
ol.Coordinate

The coordinates of the up left corner.

getUpRightCorner(mapCenter)

Get the coordinates of the up right corner of the printed map.

Parameters:
Name Type Description
mapCenter ol.Coordinate

Center of the map to print.

Returns:
ol.Coordinate

The coordinates of the up right corner.