Export Map Addon
The Export Map addon allows is used to print a copy of the map. Learn more about the Export Map add-on.x
53
1
2
<html lang="en">
3
<head>
4
<meta charset="utf-8" />
5
<link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/v4/trimblemaps-4.2.3.css" />
6
<script src="https://maps-sdk.trimblemaps.com/v4/trimblemaps-4.2.3.js"></script>
7
<script src="https://maps-sdk.trimblemaps.com/addon/trimblemaps-exportmap-2.1.0.js"></script>
8
<link rel="stylesheet" href="https://maps-sdk.trimblemaps.com/addon/trimblemaps-exportmap-2.1.0.css" />
9
<style>
10
body { margin: 0; padding: 0; }
11
12
#map {
13
position: absolute;
14
top: 0;
15
bottom: 0;
16
width: 100%;
17
}
18
</style>
19
</head>
20
<body>
21
<div id="map"></div>
22
23
<script>
24
TrimbleMaps.setAPIKey('YOUR_API_KEY_HERE');
25
const map = new TrimbleMaps.Map({
26
container: 'map', // container id
27
style: TrimbleMaps.Common.Style.TRANSPORTATION, // hosted style id
28
center: [-77.38, 39], // starting position
29
zoom: 3, // starting zoom
30
//printing requires that the renderer preserve the drawing buffer
31
preserveDrawingBuffer: true
32
});
33
34
const clientHeight = document.getElementById('map').clientHeight;
35
const clientWidth = document.getElementById('map').clientWidth;
36
37
const exportMap = new TrimbleMapsControl.ExportMap(
38
{
39
pageTitle: 'Printed Map',
40
top: 0,
41
left: 0,
42
height: clientHeight*4,
43
width: clientWidth*4,
44
addButton: true,
45
// attributionPosition: 'bottom-right', // default 'bottom-right' // 'bottom-left' // 'top-right' // 'top-left'
46
});
47
48
map.addControl(exportMap);
49
50
</script>
51
</body>
52
</html>
53