react-spatial 1.11.5 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -124,13 +124,17 @@ const propTypes = {
|
|
|
124
124
|
paddingBottom: PropTypes.number,
|
|
125
125
|
paddingBackground: PropTypes.number
|
|
126
126
|
})
|
|
127
|
-
})
|
|
127
|
+
}),
|
|
128
|
+
/**
|
|
129
|
+
* Return the file name of the image to download.
|
|
130
|
+
*/
|
|
131
|
+
getDownloadImageName: PropTypes.func
|
|
128
132
|
};
|
|
129
133
|
const getMargin = (destCanvas) => {
|
|
130
134
|
const newMargin = destCanvas.width / 100;
|
|
131
135
|
return newMargin;
|
|
132
136
|
};
|
|
133
|
-
const
|
|
137
|
+
const getDefaultDownloadImageName = (format) => {
|
|
134
138
|
const fileExt = format === "image/jpeg" ? "jpg" : "png";
|
|
135
139
|
return `${window.document.title.replace(/ /g, "_").toLowerCase()}.${fileExt}`;
|
|
136
140
|
};
|
|
@@ -378,7 +382,7 @@ const createCanvasImage = (mapToExport, extraData, scale, extent, coordinates, m
|
|
|
378
382
|
mapToExport.renderSync();
|
|
379
383
|
});
|
|
380
384
|
};
|
|
381
|
-
const downloadCanvasImage = (canvas, format) => {
|
|
385
|
+
const downloadCanvasImage = (canvas, format, getDownloadImageName) => {
|
|
382
386
|
const promise = new Promise((resolve) => {
|
|
383
387
|
if (/msie (9|10)/gi.test(window.navigator.userAgent.toLowerCase())) {
|
|
384
388
|
const url = canvas.toDataURL(format);
|
|
@@ -422,6 +426,7 @@ function CanvasSaveButton({
|
|
|
422
426
|
extent = null,
|
|
423
427
|
coordinates = null,
|
|
424
428
|
scale = 1,
|
|
429
|
+
getDownloadImageName = getDefaultDownloadImageName,
|
|
425
430
|
onSaveStart = (mapp) => {
|
|
426
431
|
return Promise.resolve(mapp);
|
|
427
432
|
},
|
|
@@ -447,9 +452,11 @@ function CanvasSaveButton({
|
|
|
447
452
|
padding
|
|
448
453
|
).then((canvas) => {
|
|
449
454
|
if (autoDownload) {
|
|
450
|
-
downloadCanvasImage(canvas, format).then(
|
|
451
|
-
|
|
452
|
-
|
|
455
|
+
downloadCanvasImage(canvas, format, getDownloadImageName).then(
|
|
456
|
+
(blob) => {
|
|
457
|
+
onSaveEnd(mapToExport, canvas, blob);
|
|
458
|
+
}
|
|
459
|
+
);
|
|
453
460
|
} else {
|
|
454
461
|
onSaveEnd(mapToExport, canvas);
|
|
455
462
|
}
|
|
@@ -472,7 +479,8 @@ function CanvasSaveButton({
|
|
|
472
479
|
onSaveEnd,
|
|
473
480
|
onSaveStart,
|
|
474
481
|
padding,
|
|
475
|
-
scale
|
|
482
|
+
scale,
|
|
483
|
+
getDownloadImageName
|
|
476
484
|
]
|
|
477
485
|
);
|
|
478
486
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, React.Children.map(children, (child) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/CanvasSaveButton/CanvasSaveButton.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-param-reassign */\nimport React, { useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { getTopLeft, getBottomRight } from \"ol/extent\";\nimport NorthArrowSimple from \"../../images/northArrow.url.svg\";\nimport NorthArrowCircle from \"../../images/northArrowCircle.url.svg\";\n\nconst extraDataImgPropType = PropTypes.shape({\n src: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n rotation: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),\n circled: PropTypes.bool,\n});\n\n// support server-side rendering where `Element` will not be defined\nconst CanvasPatternType =\n typeof CanvasPattern === \"undefined\" ? Function : CanvasPattern;\n\nconst propTypes = {\n /**\n * Automatically download the image saved.\n */\n autoDownload: PropTypes.bool,\n\n /**\n * Children content of the button.\n */\n children: PropTypes.node,\n\n /**\n * Output format of the image.\n */\n format: PropTypes.oneOf([\"image/jpeg\", \"image/png\"]),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Space (in pixels) between the border of the canvas and the elements.\n * Default to 1% of the canvas width.\n */\n margin: PropTypes.number,\n\n /**\n * Space (in pixels) between elements.\n * Default to 5px.\n */\n padding: PropTypes.number,\n\n /**\n * Extent for the export. If no extent is given, the whole map is exported.\n */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /**\n * Array of 4 [ol/Coordinate](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~Coordinate).\n * If no coordinates and no extent are given, the whole map is exported.\n * This property must be used to export rotated map.\n * If you don't need to export rotated map the extent property can be used as well.\n * If extent is specified, coordinates property is ignored.\n */\n coordinates: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),\n\n /**\n * Scale the map for better quality. Possible values: 1, 2 or 3.\n * WARNING: The tiled layer with a WMTS or XYZ source must provides an url\n * for each scale in the config file.\n */\n scale: PropTypes.number,\n\n /**\n * Function called before the dowload process begins.\n */\n onSaveStart: PropTypes.func,\n\n /**\n * Function called after the dowload process ends.\n *\n * @param {object} error Error message the process fails.\n */\n onSaveEnd: PropTypes.func,\n\n /**\n * Extra data, such as copyright, north arrow configuration.\n * All extra data is optional.\n *\n * Example 1:\n *\n {\n copyright: {\n text: 'Example copyright', // Copyright text or function\n font: '10px Arial', // Font, default is '12px Arial'\n fillStyle: 'blue', // Fill style, default is 'black'\n },\n northArrow, // True if the north arrow\n // should be placed with default configuration\n // (default image, rotation=0, circled=false)\n }\n * Example 2:\n *\n {\n northArrow: {\n src: NorthArrowCustom,\n width: 60, // Width in px, default is 80\n height: 100, // Height in px, default is 80\n rotation: 25, // Absolute rotation in degrees as number or function\n\n }\n }\n * Example 3:\n *\n {\n copyright: {\n text: () => { // Copyright as function\n return this.copyright;\n },\n },\n northArrow: {\n rotation: () => { // Rotation as function\n return NorthArrow.radToDeg(this.map.getView().getRotation());\n },\n circled, // Display circle around the north arrow (Does not work for custom src)\n },\n }\n */\n extraData: PropTypes.shape({\n logo: extraDataImgPropType,\n northArrow: extraDataImgPropType,\n qrCode: extraDataImgPropType,\n copyright: PropTypes.shape({\n text: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),\n font: PropTypes.string,\n fillStyle: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.instanceOf(CanvasPatternType),\n ]),\n background: PropTypes.bool,\n maxWidth: PropTypes.number,\n paddingBottom: PropTypes.number,\n paddingBackground: PropTypes.number,\n }),\n }),\n};\n\nconst getMargin = (destCanvas) => {\n const newMargin = destCanvas.width / 100; // 1% of the canvas width\n return newMargin;\n};\n\nconst getDownloadImageName = (format) => {\n const fileExt = format === \"image/jpeg\" ? \"jpg\" : \"png\";\n return `${window.document.title.replace(/ /g, \"_\").toLowerCase()}.${fileExt}`;\n};\n\nlet multilineCopyright = false;\nlet copyrightY = 0;\n\n// Ensure the font size fita with the image width.\nconst decreaseFontSize = (destContext, maxWidth, copyright, scale) => {\n const minFontSize = 8;\n let sizeMatch;\n let fontSize;\n do {\n sizeMatch = destContext.font.match(/[0-9]+(?:\\.[0-9]+)?(px)/i);\n fontSize = parseInt(sizeMatch[0].replace(sizeMatch[1], \"\"), 10);\n\n // eslint-disable-next-line no-param-reassign\n destContext.font = destContext.font.replace(fontSize, fontSize - 1);\n\n multilineCopyright = false;\n\n if (fontSize - 1 === minFontSize) {\n multilineCopyright = true;\n }\n } while (\n fontSize - 1 > minFontSize &&\n destContext.measureText(copyright).width * scale > maxWidth\n );\n\n return destContext.font;\n};\n\n// eslint-disable-next-line class-methods-use-this\nconst drawTextBackground = (\n destContext,\n x,\n y,\n width,\n height,\n styleOptions = {},\n) => {\n destContext.save();\n // Dflt is a white background\n destContext.fillStyle = \"rgba(255,255,255,.8)\";\n\n // To simplify usability the user could pass a boolean to use only default values.\n if (typeof styleOptions === \"object\") {\n Object.entries(styleOptions).forEach(([key, value]) => {\n destContext[key] = value;\n });\n }\n\n /// draw background rect assuming height of font\n destContext.fillRect(x, y, width, height);\n destContext.restore();\n};\n\nconst drawCopyright = (\n destContext,\n destCanvas,\n maxWidth,\n extraData,\n scale,\n margin,\n padding,\n) => {\n const { text, font, fillStyle, background } = extraData.copyright;\n const { paddingBottom = padding, paddingBackground = 2 } =\n extraData.copyright;\n\n let copyright = typeof text === \"function\" ? text() : text?.trim();\n\n if (Array.isArray(copyright)) {\n copyright = copyright.join();\n }\n\n destContext.save();\n destContext.scale(scale, scale);\n destContext.font = font || \"12px Arial\";\n destContext.font = decreaseFontSize(destContext, maxWidth, copyright, scale);\n destContext.textBaseline = \"bottom\";\n destContext.scale(scale, scale);\n destContext.fillStyle = fillStyle || \"black\";\n\n // We search if the display on 2 line is necessary\n let firstLine = copyright;\n let firstLineMetrics = destContext.measureText(firstLine);\n\n // If the text is bigger than the max width we split it into 2 lines\n if (multilineCopyright) {\n const wordNumber = copyright.split(\" \").length;\n for (let i = 0; i < wordNumber; i += 1) {\n // Stop removing word when fits within one line.\n if (firstLineMetrics.width * scale < maxWidth) {\n break;\n }\n firstLine = firstLine.substring(0, firstLine.lastIndexOf(\" \"));\n firstLineMetrics = destContext.measureText(firstLine);\n }\n }\n\n // Define second line if necessary\n const secondLine = copyright.replace(firstLine, \"\").trim();\n\n // At this point we the number of lines to display.\n const lines = [firstLine, secondLine].filter((l) => !!l).reverse();\n\n // We draw from bottom to top because textBaseline is 'bottom\n let lineX = margin;\n let lineY = destCanvas.height - paddingBottom; // we apply the margin only on the left side\n\n lines.forEach((line) => {\n const { width, fontBoundingBoxAscent, fontBoundingBoxDescent } =\n destContext.measureText(line);\n const height = fontBoundingBoxAscent + fontBoundingBoxDescent; // we include paddingBackground to have a bit of distance between lines\n let lineTop = lineY - height;\n\n if (background) {\n const backgroundX = margin;\n lineTop -= paddingBackground * 2;\n drawTextBackground(\n destContext,\n backgroundX,\n lineTop,\n width + paddingBackground * 2,\n height + paddingBackground * 2,\n background,\n );\n lineX += paddingBackground;\n lineY -= paddingBackground;\n }\n\n destContext.fillText(line, lineX, lineY);\n lineY = lineTop;\n });\n\n copyrightY = lineY;\n destContext.restore();\n};\n\nconst drawElement = (\n data,\n destCanvas,\n scale,\n margin,\n padding,\n previousItemSize = [0, 0],\n side = \"right\",\n) => {\n const destContext = destCanvas.getContext(\"2d\");\n const { src, width, height, rotation } = data;\n\n return new Promise((resolve) => {\n const img = new Image();\n img.crossOrigin = \"Anonymous\";\n img.src = src;\n img.onload = () => {\n destContext.save();\n const elementWidth = (width || 80) * scale;\n const elementHeight = (height || 80) * scale;\n const left =\n side === \"left\"\n ? margin + elementWidth / 2\n : destCanvas.width - margin - elementWidth / 2;\n const top =\n (side === \"left\" && copyrightY\n ? copyrightY - padding\n : destCanvas.height) -\n margin -\n elementHeight / 2 -\n previousItemSize[1];\n\n destContext.translate(left, top);\n\n if (rotation) {\n const angle = typeof rotation === \"function\" ? rotation() : rotation;\n destContext.rotate(angle * (Math.PI / 180));\n }\n\n destContext.drawImage(\n img,\n -elementWidth / 2,\n -elementHeight / 2,\n elementWidth,\n elementHeight,\n );\n destContext.restore();\n\n // Return the pixels width of the arrow and the margin right,\n // that must not be occupied by the copyright.\n resolve([elementWidth + 2 * padding, elementHeight + 2 * padding]);\n };\n\n img.onerror = () => {\n resolve();\n };\n });\n};\n\nconst calculatePixelsToExport = (mapToExport, extent, coordinates) => {\n let firstCoordinate;\n let oppositeCoordinate;\n\n if (extent) {\n firstCoordinate = getTopLeft(extent);\n oppositeCoordinate = getBottomRight(extent);\n } else if (coordinates) {\n // In case of coordinates coming from DragBox interaction:\n // firstCoordinate is the first coordinate drawn by the user.\n // oppositeCoordinate is the coordinate of the point dragged by the user.\n [firstCoordinate, , oppositeCoordinate] = coordinates;\n }\n\n if (firstCoordinate && oppositeCoordinate) {\n const firstPixel = mapToExport.getPixelFromCoordinate(firstCoordinate);\n const oppositePixel =\n mapToExport.getPixelFromCoordinate(oppositeCoordinate);\n const pixelTopLeft = [\n firstPixel[0] <= oppositePixel[0] ? firstPixel[0] : oppositePixel[0],\n firstPixel[1] <= oppositePixel[1] ? firstPixel[1] : oppositePixel[1],\n ];\n const pixelBottomRight = [\n firstPixel[0] > oppositePixel[0] ? firstPixel[0] : oppositePixel[0],\n firstPixel[1] > oppositePixel[1] ? firstPixel[1] : oppositePixel[1],\n ];\n\n return {\n x: pixelTopLeft[0],\n y: pixelTopLeft[1],\n w: pixelBottomRight[0] - pixelTopLeft[0],\n h: pixelBottomRight[1] - pixelTopLeft[1],\n };\n }\n return null;\n};\n\nconst createCanvasImage = (\n mapToExport,\n extraData,\n scale,\n extent,\n coordinates,\n margin,\n padding,\n) => {\n return new Promise((resolve) => {\n mapToExport.once(\"rendercomplete\", () => {\n // Find all layer canvases and add it to dest canvas.\n const canvases = mapToExport\n .getTargetElement()\n .getElementsByTagName(\"canvas\");\n\n // Create the canvas to export with the good size.\n let destCanvas;\n let destContext;\n\n // canvases is an HTMLCollection, we don't try to transform to array because some compilers like cra doesn't translate it right.\n for (let i = 0; i < canvases.length; i += 1) {\n const canvas = canvases[i];\n if (!canvas.width || !canvas.height) {\n // eslint-disable-next-line no-continue\n continue;\n }\n const clip = calculatePixelsToExport(\n mapToExport,\n extent,\n coordinates,\n ) || {\n x: 0,\n y: 0,\n w: canvas.width,\n h: canvas.height,\n };\n\n if (!destCanvas) {\n destCanvas = document.createElement(\"canvas\");\n destCanvas.width = clip.w;\n destCanvas.height = clip.h;\n destContext = destCanvas.getContext(\"2d\");\n }\n\n // Draw canvas to the canvas to export.\n destContext.drawImage(\n canvas,\n clip.x,\n clip.y,\n clip.w,\n clip.h,\n 0,\n 0,\n destCanvas.width,\n destCanvas.height,\n );\n }\n\n margin = margin || getMargin(destCanvas);\n\n // Custom info\n let logoPromise = Promise.resolve();\n if (destContext && extraData && extraData.logo) {\n logoPromise = drawElement(\n extraData.logo,\n destCanvas,\n scale,\n margin,\n padding,\n );\n }\n\n logoPromise.then((logoSize = [0, 0]) => {\n // North arrow\n let arrowPromise = Promise.resolve();\n if (destContext && extraData && extraData.northArrow) {\n arrowPromise = drawElement(\n {\n src: extraData.northArrow.circled\n ? NorthArrowCircle\n : NorthArrowSimple,\n ...extraData.northArrow,\n },\n destCanvas,\n scale,\n margin,\n padding,\n logoSize,\n );\n }\n\n // Copyright\n arrowPromise.then((arrowSize = [0, 0]) => {\n const widestElement = Math.max(logoSize[0], arrowSize[0]);\n if (\n destContext &&\n extraData &&\n extraData.copyright &&\n extraData.copyright.text\n ) {\n const maxWidth =\n extraData.copyright.maxWidth ||\n (widestElement\n ? destContext.canvas.width - widestElement - margin\n : destContext.canvas.width);\n drawCopyright(\n destContext,\n destCanvas,\n maxWidth,\n extraData,\n scale,\n margin,\n padding,\n );\n }\n let qrCodePromise = Promise.resolve();\n if (destContext && extraData && extraData.qrCode) {\n qrCodePromise = drawElement(\n extraData.qrCode,\n destCanvas,\n scale,\n margin,\n padding,\n undefined,\n \"left\",\n );\n }\n qrCodePromise.then(() => {\n return resolve(destCanvas);\n });\n });\n });\n });\n mapToExport.renderSync();\n });\n};\n\nconst downloadCanvasImage = (canvas, format) => {\n // Use blob for large images\n const promise = new Promise((resolve) => {\n if (/msie (9|10)/gi.test(window.navigator.userAgent.toLowerCase())) {\n // ie 9 and 10\n const url = canvas.toDataURL(format);\n const w = window.open(\"about:blank\", \"\");\n w.document.write(`<img src=\"${url}\" alt=\"from canvas\"/>`);\n resolve(url);\n }\n if (window.navigator.msSaveBlob) {\n // ie 11 and higher\n let image;\n try {\n image = canvas.msToBlob();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(e);\n }\n const blob = new Blob([image], {\n type: format,\n });\n resolve(blob);\n window.navigator.msSaveBlob(blob, getDownloadImageName(format));\n } else {\n canvas.toBlob((blob) => {\n const link = document.createElement(\"a\");\n link.download = getDownloadImageName(format);\n link.href = URL.createObjectURL(blob);\n // append child to document for firefox to be able to download.\n document.body.appendChild(link);\n link.click();\n resolve(blob);\n }, format);\n }\n });\n return promise;\n};\n\n/**\n * The CanvasSaveButton component creates a button to save\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html)\n * canvas as an image.\n */\nfunction CanvasSaveButton({\n margin = null,\n padding = 5,\n autoDownload = true,\n children = null,\n map = null,\n format = \"image/png\",\n extraData = null,\n extent = null,\n coordinates = null,\n scale = 1,\n onSaveStart = (mapp) => {\n return Promise.resolve(mapp);\n },\n onSaveEnd = () => {},\n}) {\n const onClick = useCallback(\n (evt) => {\n if (window.navigator.msSaveBlob) {\n // ie only\n evt.preventDefault();\n evt.stopPropagation();\n }\n multilineCopyright = false;\n copyrightY = 0;\n onSaveStart(map).then((mapToExport) => {\n return createCanvasImage(\n mapToExport || map,\n extraData,\n scale,\n extent,\n coordinates,\n margin,\n padding,\n )\n .then((canvas) => {\n if (autoDownload) {\n downloadCanvasImage(canvas, format).then((blob) => {\n onSaveEnd(mapToExport, canvas, blob);\n });\n } else {\n onSaveEnd(mapToExport, canvas);\n }\n })\n .catch((err) => {\n if (err) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n onSaveEnd(mapToExport, err);\n });\n });\n },\n [\n autoDownload,\n coordinates,\n extent,\n extraData,\n format,\n map,\n margin,\n onSaveEnd,\n onSaveStart,\n padding,\n scale,\n ],\n );\n\n return (\n <>\n {React.Children.map(children, (child) => {\n return React.cloneElement(child, { onClick });\n })}\n </>\n );\n}\n\nCanvasSaveButton.propTypes = propTypes;\n\nexport default CanvasSaveButton;\n"],
|
|
5
|
-
"mappings": "AACA,OAAO,SAAS,mBAAmB;AACnC,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,YAAY,sBAAsB;AAC3C,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,uBAAuB,UAAU,MAAM;AAAA,EAC3C,KAAK,UAAU;AAAA,EACf,OAAO,UAAU;AAAA,EACjB,QAAQ,UAAU;AAAA,EAClB,UAAU,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU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,UAAU;AAAA,QAC7B,UAAU;AAAA,QACV,UAAU,WAAW,iBAAiB;AAAA,MACxC,CAAC;AAAA,MACD,YAAY,UAAU;AAAA,MACtB,UAAU,UAAU;AAAA,MACpB,eAAe,UAAU;AAAA,MACzB,mBAAmB,UAAU;AAAA,IAC/B,CAAC;AAAA,EACH,CAAC;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-param-reassign */\nimport React, { useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport OLMap from \"ol/Map\";\nimport { getTopLeft, getBottomRight } from \"ol/extent\";\nimport NorthArrowSimple from \"../../images/northArrow.url.svg\";\nimport NorthArrowCircle from \"../../images/northArrowCircle.url.svg\";\n\nconst extraDataImgPropType = PropTypes.shape({\n src: PropTypes.string,\n width: PropTypes.number,\n height: PropTypes.number,\n rotation: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),\n circled: PropTypes.bool,\n});\n\n// support server-side rendering where `Element` will not be defined\nconst CanvasPatternType =\n typeof CanvasPattern === \"undefined\" ? Function : CanvasPattern;\n\nconst propTypes = {\n /**\n * Automatically download the image saved.\n */\n autoDownload: PropTypes.bool,\n\n /**\n * Children content of the button.\n */\n children: PropTypes.node,\n\n /**\n * Output format of the image.\n */\n format: PropTypes.oneOf([\"image/jpeg\", \"image/png\"]),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Space (in pixels) between the border of the canvas and the elements.\n * Default to 1% of the canvas width.\n */\n margin: PropTypes.number,\n\n /**\n * Space (in pixels) between elements.\n * Default to 5px.\n */\n padding: PropTypes.number,\n\n /**\n * Extent for the export. If no extent is given, the whole map is exported.\n */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /**\n * Array of 4 [ol/Coordinate](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~Coordinate).\n * If no coordinates and no extent are given, the whole map is exported.\n * This property must be used to export rotated map.\n * If you don't need to export rotated map the extent property can be used as well.\n * If extent is specified, coordinates property is ignored.\n */\n coordinates: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),\n\n /**\n * Scale the map for better quality. Possible values: 1, 2 or 3.\n * WARNING: The tiled layer with a WMTS or XYZ source must provides an url\n * for each scale in the config file.\n */\n scale: PropTypes.number,\n\n /**\n * Function called before the dowload process begins.\n */\n onSaveStart: PropTypes.func,\n\n /**\n * Function called after the dowload process ends.\n *\n * @param {object} error Error message the process fails.\n */\n onSaveEnd: PropTypes.func,\n\n /**\n * Extra data, such as copyright, north arrow configuration.\n * All extra data is optional.\n *\n * Example 1:\n *\n {\n copyright: {\n text: 'Example copyright', // Copyright text or function\n font: '10px Arial', // Font, default is '12px Arial'\n fillStyle: 'blue', // Fill style, default is 'black'\n },\n northArrow, // True if the north arrow\n // should be placed with default configuration\n // (default image, rotation=0, circled=false)\n }\n * Example 2:\n *\n {\n northArrow: {\n src: NorthArrowCustom,\n width: 60, // Width in px, default is 80\n height: 100, // Height in px, default is 80\n rotation: 25, // Absolute rotation in degrees as number or function\n\n }\n }\n * Example 3:\n *\n {\n copyright: {\n text: () => { // Copyright as function\n return this.copyright;\n },\n },\n northArrow: {\n rotation: () => { // Rotation as function\n return NorthArrow.radToDeg(this.map.getView().getRotation());\n },\n circled, // Display circle around the north arrow (Does not work for custom src)\n },\n }\n */\n extraData: PropTypes.shape({\n logo: extraDataImgPropType,\n northArrow: extraDataImgPropType,\n qrCode: extraDataImgPropType,\n copyright: PropTypes.shape({\n text: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),\n font: PropTypes.string,\n fillStyle: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.instanceOf(CanvasPatternType),\n ]),\n background: PropTypes.bool,\n maxWidth: PropTypes.number,\n paddingBottom: PropTypes.number,\n paddingBackground: PropTypes.number,\n }),\n }),\n\n /**\n * Return the file name of the image to download.\n */\n getDownloadImageName: PropTypes.func,\n};\n\nconst getMargin = (destCanvas) => {\n const newMargin = destCanvas.width / 100; // 1% of the canvas width\n return newMargin;\n};\n\nconst getDefaultDownloadImageName = (format) => {\n const fileExt = format === \"image/jpeg\" ? \"jpg\" : \"png\";\n return `${window.document.title.replace(/ /g, \"_\").toLowerCase()}.${fileExt}`;\n};\n\nlet multilineCopyright = false;\nlet copyrightY = 0;\n\n// Ensure the font size fita with the image width.\nconst decreaseFontSize = (destContext, maxWidth, copyright, scale) => {\n const minFontSize = 8;\n let sizeMatch;\n let fontSize;\n do {\n sizeMatch = destContext.font.match(/[0-9]+(?:\\.[0-9]+)?(px)/i);\n fontSize = parseInt(sizeMatch[0].replace(sizeMatch[1], \"\"), 10);\n\n // eslint-disable-next-line no-param-reassign\n destContext.font = destContext.font.replace(fontSize, fontSize - 1);\n\n multilineCopyright = false;\n\n if (fontSize - 1 === minFontSize) {\n multilineCopyright = true;\n }\n } while (\n fontSize - 1 > minFontSize &&\n destContext.measureText(copyright).width * scale > maxWidth\n );\n\n return destContext.font;\n};\n\n// eslint-disable-next-line class-methods-use-this\nconst drawTextBackground = (\n destContext,\n x,\n y,\n width,\n height,\n styleOptions = {},\n) => {\n destContext.save();\n // Dflt is a white background\n destContext.fillStyle = \"rgba(255,255,255,.8)\";\n\n // To simplify usability the user could pass a boolean to use only default values.\n if (typeof styleOptions === \"object\") {\n Object.entries(styleOptions).forEach(([key, value]) => {\n destContext[key] = value;\n });\n }\n\n /// draw background rect assuming height of font\n destContext.fillRect(x, y, width, height);\n destContext.restore();\n};\n\nconst drawCopyright = (\n destContext,\n destCanvas,\n maxWidth,\n extraData,\n scale,\n margin,\n padding,\n) => {\n const { text, font, fillStyle, background } = extraData.copyright;\n const { paddingBottom = padding, paddingBackground = 2 } =\n extraData.copyright;\n\n let copyright = typeof text === \"function\" ? text() : text?.trim();\n\n if (Array.isArray(copyright)) {\n copyright = copyright.join();\n }\n\n destContext.save();\n destContext.scale(scale, scale);\n destContext.font = font || \"12px Arial\";\n destContext.font = decreaseFontSize(destContext, maxWidth, copyright, scale);\n destContext.textBaseline = \"bottom\";\n destContext.scale(scale, scale);\n destContext.fillStyle = fillStyle || \"black\";\n\n // We search if the display on 2 line is necessary\n let firstLine = copyright;\n let firstLineMetrics = destContext.measureText(firstLine);\n\n // If the text is bigger than the max width we split it into 2 lines\n if (multilineCopyright) {\n const wordNumber = copyright.split(\" \").length;\n for (let i = 0; i < wordNumber; i += 1) {\n // Stop removing word when fits within one line.\n if (firstLineMetrics.width * scale < maxWidth) {\n break;\n }\n firstLine = firstLine.substring(0, firstLine.lastIndexOf(\" \"));\n firstLineMetrics = destContext.measureText(firstLine);\n }\n }\n\n // Define second line if necessary\n const secondLine = copyright.replace(firstLine, \"\").trim();\n\n // At this point we the number of lines to display.\n const lines = [firstLine, secondLine].filter((l) => !!l).reverse();\n\n // We draw from bottom to top because textBaseline is 'bottom\n let lineX = margin;\n let lineY = destCanvas.height - paddingBottom; // we apply the margin only on the left side\n\n lines.forEach((line) => {\n const { width, fontBoundingBoxAscent, fontBoundingBoxDescent } =\n destContext.measureText(line);\n const height = fontBoundingBoxAscent + fontBoundingBoxDescent; // we include paddingBackground to have a bit of distance between lines\n let lineTop = lineY - height;\n\n if (background) {\n const backgroundX = margin;\n lineTop -= paddingBackground * 2;\n drawTextBackground(\n destContext,\n backgroundX,\n lineTop,\n width + paddingBackground * 2,\n height + paddingBackground * 2,\n background,\n );\n lineX += paddingBackground;\n lineY -= paddingBackground;\n }\n\n destContext.fillText(line, lineX, lineY);\n lineY = lineTop;\n });\n\n copyrightY = lineY;\n destContext.restore();\n};\n\nconst drawElement = (\n data,\n destCanvas,\n scale,\n margin,\n padding,\n previousItemSize = [0, 0],\n side = \"right\",\n) => {\n const destContext = destCanvas.getContext(\"2d\");\n const { src, width, height, rotation } = data;\n\n return new Promise((resolve) => {\n const img = new Image();\n img.crossOrigin = \"Anonymous\";\n img.src = src;\n img.onload = () => {\n destContext.save();\n const elementWidth = (width || 80) * scale;\n const elementHeight = (height || 80) * scale;\n const left =\n side === \"left\"\n ? margin + elementWidth / 2\n : destCanvas.width - margin - elementWidth / 2;\n const top =\n (side === \"left\" && copyrightY\n ? copyrightY - padding\n : destCanvas.height) -\n margin -\n elementHeight / 2 -\n previousItemSize[1];\n\n destContext.translate(left, top);\n\n if (rotation) {\n const angle = typeof rotation === \"function\" ? rotation() : rotation;\n destContext.rotate(angle * (Math.PI / 180));\n }\n\n destContext.drawImage(\n img,\n -elementWidth / 2,\n -elementHeight / 2,\n elementWidth,\n elementHeight,\n );\n destContext.restore();\n\n // Return the pixels width of the arrow and the margin right,\n // that must not be occupied by the copyright.\n resolve([elementWidth + 2 * padding, elementHeight + 2 * padding]);\n };\n\n img.onerror = () => {\n resolve();\n };\n });\n};\n\nconst calculatePixelsToExport = (mapToExport, extent, coordinates) => {\n let firstCoordinate;\n let oppositeCoordinate;\n\n if (extent) {\n firstCoordinate = getTopLeft(extent);\n oppositeCoordinate = getBottomRight(extent);\n } else if (coordinates) {\n // In case of coordinates coming from DragBox interaction:\n // firstCoordinate is the first coordinate drawn by the user.\n // oppositeCoordinate is the coordinate of the point dragged by the user.\n [firstCoordinate, , oppositeCoordinate] = coordinates;\n }\n\n if (firstCoordinate && oppositeCoordinate) {\n const firstPixel = mapToExport.getPixelFromCoordinate(firstCoordinate);\n const oppositePixel =\n mapToExport.getPixelFromCoordinate(oppositeCoordinate);\n const pixelTopLeft = [\n firstPixel[0] <= oppositePixel[0] ? firstPixel[0] : oppositePixel[0],\n firstPixel[1] <= oppositePixel[1] ? firstPixel[1] : oppositePixel[1],\n ];\n const pixelBottomRight = [\n firstPixel[0] > oppositePixel[0] ? firstPixel[0] : oppositePixel[0],\n firstPixel[1] > oppositePixel[1] ? firstPixel[1] : oppositePixel[1],\n ];\n\n return {\n x: pixelTopLeft[0],\n y: pixelTopLeft[1],\n w: pixelBottomRight[0] - pixelTopLeft[0],\n h: pixelBottomRight[1] - pixelTopLeft[1],\n };\n }\n return null;\n};\n\nconst createCanvasImage = (\n mapToExport,\n extraData,\n scale,\n extent,\n coordinates,\n margin,\n padding,\n) => {\n return new Promise((resolve) => {\n mapToExport.once(\"rendercomplete\", () => {\n // Find all layer canvases and add it to dest canvas.\n const canvases = mapToExport\n .getTargetElement()\n .getElementsByTagName(\"canvas\");\n\n // Create the canvas to export with the good size.\n let destCanvas;\n let destContext;\n\n // canvases is an HTMLCollection, we don't try to transform to array because some compilers like cra doesn't translate it right.\n for (let i = 0; i < canvases.length; i += 1) {\n const canvas = canvases[i];\n if (!canvas.width || !canvas.height) {\n // eslint-disable-next-line no-continue\n continue;\n }\n const clip = calculatePixelsToExport(\n mapToExport,\n extent,\n coordinates,\n ) || {\n x: 0,\n y: 0,\n w: canvas.width,\n h: canvas.height,\n };\n\n if (!destCanvas) {\n destCanvas = document.createElement(\"canvas\");\n destCanvas.width = clip.w;\n destCanvas.height = clip.h;\n destContext = destCanvas.getContext(\"2d\");\n }\n\n // Draw canvas to the canvas to export.\n destContext.drawImage(\n canvas,\n clip.x,\n clip.y,\n clip.w,\n clip.h,\n 0,\n 0,\n destCanvas.width,\n destCanvas.height,\n );\n }\n\n margin = margin || getMargin(destCanvas);\n\n // Custom info\n let logoPromise = Promise.resolve();\n if (destContext && extraData && extraData.logo) {\n logoPromise = drawElement(\n extraData.logo,\n destCanvas,\n scale,\n margin,\n padding,\n );\n }\n\n logoPromise.then((logoSize = [0, 0]) => {\n // North arrow\n let arrowPromise = Promise.resolve();\n if (destContext && extraData && extraData.northArrow) {\n arrowPromise = drawElement(\n {\n src: extraData.northArrow.circled\n ? NorthArrowCircle\n : NorthArrowSimple,\n ...extraData.northArrow,\n },\n destCanvas,\n scale,\n margin,\n padding,\n logoSize,\n );\n }\n\n // Copyright\n arrowPromise.then((arrowSize = [0, 0]) => {\n const widestElement = Math.max(logoSize[0], arrowSize[0]);\n if (\n destContext &&\n extraData &&\n extraData.copyright &&\n extraData.copyright.text\n ) {\n const maxWidth =\n extraData.copyright.maxWidth ||\n (widestElement\n ? destContext.canvas.width - widestElement - margin\n : destContext.canvas.width);\n drawCopyright(\n destContext,\n destCanvas,\n maxWidth,\n extraData,\n scale,\n margin,\n padding,\n );\n }\n let qrCodePromise = Promise.resolve();\n if (destContext && extraData && extraData.qrCode) {\n qrCodePromise = drawElement(\n extraData.qrCode,\n destCanvas,\n scale,\n margin,\n padding,\n undefined,\n \"left\",\n );\n }\n qrCodePromise.then(() => {\n return resolve(destCanvas);\n });\n });\n });\n });\n mapToExport.renderSync();\n });\n};\n\nconst downloadCanvasImage = (canvas, format, getDownloadImageName) => {\n // Use blob for large images\n const promise = new Promise((resolve) => {\n if (/msie (9|10)/gi.test(window.navigator.userAgent.toLowerCase())) {\n // ie 9 and 10\n const url = canvas.toDataURL(format);\n const w = window.open(\"about:blank\", \"\");\n w.document.write(`<img src=\"${url}\" alt=\"from canvas\"/>`);\n resolve(url);\n }\n if (window.navigator.msSaveBlob) {\n // ie 11 and higher\n let image;\n try {\n image = canvas.msToBlob();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log(e);\n }\n const blob = new Blob([image], {\n type: format,\n });\n resolve(blob);\n window.navigator.msSaveBlob(blob, getDownloadImageName(format));\n } else {\n canvas.toBlob((blob) => {\n const link = document.createElement(\"a\");\n link.download = getDownloadImageName(format);\n link.href = URL.createObjectURL(blob);\n // append child to document for firefox to be able to download.\n document.body.appendChild(link);\n link.click();\n resolve(blob);\n }, format);\n }\n });\n return promise;\n};\n\n/**\n * The CanvasSaveButton component creates a button to save\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html)\n * canvas as an image.\n */\nfunction CanvasSaveButton({\n margin = null,\n padding = 5,\n autoDownload = true,\n children = null,\n map = null,\n format = \"image/png\",\n extraData = null,\n extent = null,\n coordinates = null,\n scale = 1,\n getDownloadImageName = getDefaultDownloadImageName,\n onSaveStart = (mapp) => {\n return Promise.resolve(mapp);\n },\n onSaveEnd = () => {},\n}) {\n const onClick = useCallback(\n (evt) => {\n if (window.navigator.msSaveBlob) {\n // ie only\n evt.preventDefault();\n evt.stopPropagation();\n }\n multilineCopyright = false;\n copyrightY = 0;\n onSaveStart(map).then((mapToExport) => {\n return createCanvasImage(\n mapToExport || map,\n extraData,\n scale,\n extent,\n coordinates,\n margin,\n padding,\n )\n .then((canvas) => {\n if (autoDownload) {\n downloadCanvasImage(canvas, format, getDownloadImageName).then(\n (blob) => {\n onSaveEnd(mapToExport, canvas, blob);\n },\n );\n } else {\n onSaveEnd(mapToExport, canvas);\n }\n })\n .catch((err) => {\n if (err) {\n // eslint-disable-next-line no-console\n console.error(err);\n }\n onSaveEnd(mapToExport, err);\n });\n });\n },\n [\n autoDownload,\n coordinates,\n extent,\n extraData,\n format,\n map,\n margin,\n onSaveEnd,\n onSaveStart,\n padding,\n scale,\n getDownloadImageName,\n ],\n );\n\n return (\n <>\n {React.Children.map(children, (child) => {\n return React.cloneElement(child, { onClick });\n })}\n </>\n );\n}\n\nCanvasSaveButton.propTypes = propTypes;\n\nexport default CanvasSaveButton;\n"],
|
|
5
|
+
"mappings": "AACA,OAAO,SAAS,mBAAmB;AACnC,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,YAAY,sBAAsB;AAC3C,OAAO,sBAAsB;AAC7B,OAAO,sBAAsB;AAE7B,MAAM,uBAAuB,UAAU,MAAM;AAAA,EAC3C,KAAK,UAAU;AAAA,EACf,OAAO,UAAU;AAAA,EACjB,QAAQ,UAAU;AAAA,EAClB,UAAU,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,IAAI,CAAC;AAAA,EAChE,SAAS,UAAU;AACrB,CAAC;AAGD,MAAM,oBACJ,OAAO,kBAAkB,cAAc,WAAW;AAEpD,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAKxB,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA,EAKpB,QAAQ,UAAU,MAAM,CAAC,cAAc,WAAW,CAAC;AAAA;AAAA,EAGnD,KAAK,UAAU,WAAW,KAAK;AAAA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