@trimblemaps/trimblemaps-exportmap
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2022, Trimble, Inc. | ||
Copyright (c) 2024, Trimble, Inc. | ||
@@ -13,3 +13,3 @@ All rights reserved. | ||
and/or other materials provided with the distribution. | ||
* Neither the name of Mapbox GL JS nor the names of its contributors | ||
* Neither the name of Trimble Maps JS nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
@@ -16,0 +16,0 @@ without specific prior written permission. |
{ | ||
"name": "@trimblemaps/trimblemaps-exportmap", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Map control for exporting map image in the JavaScript Maps SDK.", | ||
@@ -5,0 +5,0 @@ "main": "trimblemaps-exportmap.js", |
# @trimblemaps/trimblemaps-exportmap | ||
Export Map Addon for the JavaScript Maps SDK. | ||
Export Map Addon allows printing of the map for the JavaScript Maps SDK. | ||
See the [Trimble MAPS Developer Portal](https://developer.trimblemaps.com/maps-sdk/) for more information. | ||
![Export map Screenshot](https://developer.trimblemaps.com/maps-sdk/img/examples/export-map-addon.png) | ||
- [Documentation](https://developer.trimblemaps.com/maps-sdk/guide/add-ons/export-map/) | ||
- [Demo](https://developer.trimblemaps.com/maps-sdk/examples/export-map-addon/) | ||
- [Release Notes](https://developer.trimblemaps.com/maps-sdk/release-notes/) | ||
- [License](https://developer.trimblemaps.com/maps-sdk/legal/license/) | ||
See the [Trimble Maps Developer Portal](https://developer.trimblemaps.com/maps-sdk/) for more information. |
import TrimbleMaps from '@trimblemaps/trimblemaps-js'; | ||
declare type ExportOptions = { | ||
type ExportOptions = { | ||
pageTitle?: string; | ||
@@ -11,3 +11,3 @@ top?: number; | ||
}; | ||
declare type ExportMapOptions = { | ||
type ExportMapOptions = { | ||
addButton?: boolean; | ||
@@ -14,0 +14,0 @@ } & ExportOptions; |
@@ -1,1 +0,1 @@ | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):((t="undefined"!=typeof globalThis?globalThis:t||self).TrimbleMapsControl=t.TrimbleMapsControl||{},t.TrimbleMapsControl.ExportMap=o())}(this,(function(){"use strict";var t={pageTitle:"Trimble Maps",top:0,left:0,width:screen.availWidth,height:screen.availHeight,attributionPosition:"bottom-right"},o=function(){function o(t){this._addButton=(null==t?void 0:t.addButton)||!1,this.updateOptions(t)}return o.prototype.onAdd=function(t){var o=this;if(this._map=t,!0!==t._preserveDrawingBuffer&&console.warn("Must set map option preserveDrawingBuffer to true when a map is constructed."),this._container=document.createElement("div"),!0===this._addButton){this._container.className="trimblemaps-ctrl trimblemaps-ctrl-group trimblemaps-menu-ctrl";var n=document.createElement("button");n.className="trimblemaps-ctrl-icon trimblemaps-menu-exportmap-button",n.title="Export Map",n.type="button",n.addEventListener("click",(function(){o.export()})),this._container.appendChild(n)}return this._container},o.prototype.onRemove=function(){this._map&&(this._container.parentNode.removeChild(this._container),this._map=void 0)},o.prototype.updateOptions=function(o){this._options=function(t){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];for(var i=0,e=o;i<e.length;i++){var a=e[i];for(var s in a)t[s]=a[s]}return t}({},t,o)},o.prototype.export=function(){if(this._map){var t=this._map.getCanvas().toDataURL("image/png"),o=this._options.width,n=this._options.height,i="<span>\n © Trimble Inc. - Certain POI data by Infogroup © ".concat((new Date).getFullYear(),". | © OpenMapTiles © OpenStreetMap contributors\n </span>"),e='<div style="position: absolute; right: 0; bottom: 0;" class="attribution">\n '.concat(i,"\n </div>");"bottom-left"===this._options.attributionPosition&&(e='<div style="position: absolute; left: 0; bottom: 0;" class="attribution">\n '.concat(i,"\n </div>")),"top-right"===this._options.attributionPosition&&(e='<div style="position: absolute; right: 0; top: 0;" class="attribution">\n '.concat(i,"\n </div>")),"top-left"===this._options.attributionPosition&&(e='<div style="position: absolute; left: 0; top: 0;" class="attribution">\n '.concat(i,"\n </div>"));var a="<!DOCTYPE html>\n <html>\n <head>\n <title>".concat(this._options.pageTitle,"</title>\n <style>\n .attribution {padding: 4px; background-color: #fff; margin: 10px 10px 14px 10px; font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;}\n </style>\n </head>\n <body>\n <div style=\"position: relative; max-width:").concat(o,'px;">\n <img alt="map" src="').concat(t,'">\n ').concat(e,"\n </div>\n </body>\n </html>"),s=o+30>screen.availWidth?screen.availWidth:o+30,r=n+30>screen.availHeight?screen.availHeight:n+30,p="top=".concat(this._options.top,", left=").concat(this._options.left,", width=").concat(s,", height=").concat(r,", noopener=false,"),c=window.open("","",p);c.document.open(),c.document.write(a),c.document.addEventListener("load",(function(){c.focus(),c.document.close(),c.print(),setTimeout((function(){c.close()}),800)}),{capture:!0,once:!0})}},o}();return o})); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):((t="undefined"!=typeof globalThis?globalThis:t||self).TrimbleMapsControl=t.TrimbleMapsControl||{},t.TrimbleMapsControl.ExportMap=n())}(this,(function(){"use strict";var t={pageTitle:"Trimble Maps",top:0,left:0,width:screen.availWidth,height:screen.availHeight,attributionPosition:"bottom-right"},n=function(){function n(t){this._addButton=(null==t?void 0:t.addButton)||!1,this.updateOptions(t)}return n.prototype.onAdd=function(t){var n=this;if(this._map=t,!0!==t._preserveDrawingBuffer&&console.warn("Must set map option preserveDrawingBuffer to true when a map is constructed."),this._container=document.createElement("div"),!0===this._addButton){this._container.className="trimblemaps-ctrl trimblemaps-ctrl-group trimblemaps-menu-ctrl";var e=document.createElement("button");e.className="trimblemaps-ctrl-icon trimblemaps-menu-exportmap-button",e.title="Export Map",e.type="button",e.addEventListener("click",(function(){n.export()})),this._container.appendChild(e)}return this._container},n.prototype.onRemove=function(){this._map&&(this._container.parentNode.removeChild(this._container),this._map=void 0)},n.prototype.updateOptions=function(n){this._options=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];for(var i=0,o=n;i<o.length;i++){var a=o[i];for(var s in a)t[s]=a[s]}return t}({},t,n)},n.prototype.export=function(){if(this._map){var t=this._map.getCanvas().toDataURL("image/png"),n=this._options.width,e=this._options.height,i="<span>\n © Trimble Inc. - Certain POI data by Infogroup © ".concat((new Date).getFullYear(),". | © OpenMapTiles © OpenStreetMap contributors\n </span>"),o='<div style="bottom: 0; right: 0;" class="adjustable-div">'.concat(i,"</div>");"bottom-left"===this._options.attributionPosition&&(o='<div style="bottom: 0; left: 0;" class="adjustable-div">'.concat(i,"</div>")),"top-right"===this._options.attributionPosition&&(o='<div style="top: 0; right: 0;" class="adjustable-div">'.concat(i,"</div>")),"top-left"===this._options.attributionPosition&&(o='<div style="top: 0; left: 0;" class="adjustable-div">'.concat(i,"</div>"));var a="<!DOCTYPE html>\n <html>\n <head>\n <title>".concat(this._options.pageTitle,'</title>\n <style>\n .scrollable-container {\n position: relative;\n max-height: 600px;\n }\n\n .content {\n position: relative;\n }\n\n .adjustable-div {\n padding: 4px; \n background-color: #fff; \n margin: 10px 10px 14px 10px; \n font: 12px/20px \'Helvetica Neue\', Arial, Helvetica, sans-serif;\n position: absolute;\n }\n </style>\n </head>\n <body>\n <div class="scrollable-container">\n <div class="content">\n <div><img alt="map" id="tm-printmap" src="').concat(t,'"></div>\n ').concat(o,"\n </div>\n </div>\n </body>\n </html>"),s=n+30>screen.availWidth?screen.availWidth:n+30,r=e+30>screen.availHeight?screen.availHeight:e+30,p="top=".concat(this._options.top,", left=").concat(this._options.left,", width=").concat(s,", height=").concat(r,", noopener=false,"),c=window.open("","",p);c.document.open(),c.document.write(a),c.document.addEventListener("load",(function(){c.focus(),c.document.close(),c.print(),setTimeout((function(){c.close()}),800)}),{capture:!0,once:!0})}},n}();return n})); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10110
13
92