@maptiler/sdk 1.0.0

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.
Files changed (203) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +10 -0
  3. package/.github/workflows/npm-publish.yml +23 -0
  4. package/LICENSE +29 -0
  5. package/demos/maptiler-sdk.css +147 -0
  6. package/demos/maptiler-sdk.umd.js +3287 -0
  7. package/demos/simple.html +63 -0
  8. package/dist/maptiler-sdk.css +147 -0
  9. package/dist/maptiler-sdk.d.ts +531 -0
  10. package/dist/maptiler-sdk.min.mjs +1 -0
  11. package/dist/maptiler-sdk.mjs +1128 -0
  12. package/dist/maptiler-sdk.mjs.map +1 -0
  13. package/dist/maptiler-sdk.umd.js +3287 -0
  14. package/dist/maptiler-sdk.umd.js.map +1 -0
  15. package/dist/maptiler-sdk.umd.min.js +579 -0
  16. package/docs/.nojekyll +1 -0
  17. package/docs/assets/custom.css +118 -0
  18. package/docs/assets/highlight.css +134 -0
  19. package/docs/assets/main.js +54 -0
  20. package/docs/assets/search.js +1 -0
  21. package/docs/assets/style.css +1257 -0
  22. package/docs/classes/Map.html +273 -0
  23. package/docs/classes/Point.html +549 -0
  24. package/docs/classes/SdkConfig.html +188 -0
  25. package/docs/demos/maptiler-sdk.css +147 -0
  26. package/docs/demos/maptiler-sdk.umd.js +3287 -0
  27. package/docs/demos/simple.html +63 -0
  28. package/docs/functions/addProtocol.html +146 -0
  29. package/docs/functions/clearPrewarmedResources.html +92 -0
  30. package/docs/functions/clearStorage.html +124 -0
  31. package/docs/functions/getRTLTextPluginStatus.html +92 -0
  32. package/docs/functions/prewarm.html +92 -0
  33. package/docs/functions/removeProtocol.html +106 -0
  34. package/docs/functions/setRTLTextPlugin.html +112 -0
  35. package/docs/functions/supported.html +97 -0
  36. package/docs/images/JS-logo.svg +4 -0
  37. package/docs/images/TS-logo.svg +6 -0
  38. package/docs/images/maptiler-logo.svg +19 -0
  39. package/docs/images/maptiler-sdk-logo.afdesign +0 -0
  40. package/docs/images/maptiler-sdk-logo.svg +66 -0
  41. package/docs/images/screenshots/alps.gif +0 -0
  42. package/docs/images/screenshots/grandcanyon.gif +0 -0
  43. package/docs/images/screenshots/lang-arabic.png +0 -0
  44. package/docs/images/screenshots/lang-hebrew.png +0 -0
  45. package/docs/images/screenshots/multilang.gif +0 -0
  46. package/docs/images/screenshots/static-bounded-europe-1024.png +0 -0
  47. package/docs/images/screenshots/static-bounded-europe-2048.png +0 -0
  48. package/docs/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  49. package/docs/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  50. package/docs/images/screenshots/static-with-path.png +0 -0
  51. package/docs/images/screenshots/style-basic-v2.png +0 -0
  52. package/docs/images/screenshots/style-bright.png +0 -0
  53. package/docs/images/screenshots/style-dataviz-dark.png +0 -0
  54. package/docs/images/screenshots/style-hybrid.png +0 -0
  55. package/docs/images/screenshots/style-osm.png +0 -0
  56. package/docs/images/screenshots/style-outdoor.png +0 -0
  57. package/docs/images/screenshots/style-pastel.png +0 -0
  58. package/docs/images/screenshots/style-satellite.png +0 -0
  59. package/docs/images/screenshots/style-streets-v2-dark.png +0 -0
  60. package/docs/images/screenshots/style-streets-v2-light.png +0 -0
  61. package/docs/images/screenshots/style-streets-v2.png +0 -0
  62. package/docs/images/screenshots/style-toner.png +0 -0
  63. package/docs/images/screenshots/style-topo.png +0 -0
  64. package/docs/images/screenshots/style-topographique.png +0 -0
  65. package/docs/images/screenshots/style-voyager.png +0 -0
  66. package/docs/images/screenshots/style-winter.png +0 -0
  67. package/docs/index.html +601 -0
  68. package/docs/modules.html +142 -0
  69. package/docs/types/LanguageKey.html +90 -0
  70. package/docs/types/LanguageString.html +90 -0
  71. package/docs/types/MapOptions.html +90 -0
  72. package/docs/types/Matrix2.html +90 -0
  73. package/docs/types/Unit.html +88 -0
  74. package/docs/variables/AJAXError.html +88 -0
  75. package/docs/variables/AttributionControl.html +88 -0
  76. package/docs/variables/CanvasSource.html +88 -0
  77. package/docs/variables/Evented.html +88 -0
  78. package/docs/variables/FullscreenControl.html +88 -0
  79. package/docs/variables/GeoJSONSource.html +88 -0
  80. package/docs/variables/GeolocateControl.html +88 -0
  81. package/docs/variables/GeolocationType.html +95 -0
  82. package/docs/variables/ImageSource.html +88 -0
  83. package/docs/variables/Language.html +249 -0
  84. package/docs/variables/LngLat.html +88 -0
  85. package/docs/variables/LngLatBounds.html +88 -0
  86. package/docs/variables/LogoControl.html +88 -0
  87. package/docs/variables/Marker.html +88 -0
  88. package/docs/variables/MercatorCoordinate.html +88 -0
  89. package/docs/variables/NavigationControl.html +88 -0
  90. package/docs/variables/Popup.html +88 -0
  91. package/docs/variables/RasterDEMTileSource.html +88 -0
  92. package/docs/variables/RasterTileSource.html +88 -0
  93. package/docs/variables/ScaleControl.html +88 -0
  94. package/docs/variables/Style.html +88 -0
  95. package/docs/variables/TerrainControl.html +88 -0
  96. package/docs/variables/VectorTileSource.html +88 -0
  97. package/docs/variables/VideoSource.html +88 -0
  98. package/docs/variables/config.html +88 -0
  99. package/docs/variables/maxParallelImageRequests.html +88 -0
  100. package/docs/variables/version.html +88 -0
  101. package/docs/variables/workerCount.html +88 -0
  102. package/docs/variables/workerUrl.html +88 -0
  103. package/docsmd/.nojekyll +1 -0
  104. package/docsmd/README.md +710 -0
  105. package/docsmd/assets/custom.css +118 -0
  106. package/docsmd/classes/Map.md +292 -0
  107. package/docsmd/classes/Point.md +603 -0
  108. package/docsmd/classes/SdkConfig.md +186 -0
  109. package/docsmd/images/JS-logo.svg +4 -0
  110. package/docsmd/images/TS-logo.svg +6 -0
  111. package/docsmd/images/maptiler-logo.svg +19 -0
  112. package/docsmd/images/maptiler-sdk-logo.afdesign +0 -0
  113. package/docsmd/images/maptiler-sdk-logo.svg +66 -0
  114. package/docsmd/images/screenshots/alps.gif +0 -0
  115. package/docsmd/images/screenshots/grandcanyon.gif +0 -0
  116. package/docsmd/images/screenshots/lang-arabic.png +0 -0
  117. package/docsmd/images/screenshots/lang-hebrew.png +0 -0
  118. package/docsmd/images/screenshots/multilang.gif +0 -0
  119. package/docsmd/images/screenshots/static-bounded-europe-1024.png +0 -0
  120. package/docsmd/images/screenshots/static-bounded-europe-2048.png +0 -0
  121. package/docsmd/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  122. package/docsmd/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  123. package/docsmd/images/screenshots/static-with-path.png +0 -0
  124. package/docsmd/images/screenshots/style-basic-v2.png +0 -0
  125. package/docsmd/images/screenshots/style-bright.png +0 -0
  126. package/docsmd/images/screenshots/style-dataviz-dark.png +0 -0
  127. package/docsmd/images/screenshots/style-hybrid.png +0 -0
  128. package/docsmd/images/screenshots/style-osm.png +0 -0
  129. package/docsmd/images/screenshots/style-outdoor.png +0 -0
  130. package/docsmd/images/screenshots/style-pastel.png +0 -0
  131. package/docsmd/images/screenshots/style-satellite.png +0 -0
  132. package/docsmd/images/screenshots/style-streets-v2-dark.png +0 -0
  133. package/docsmd/images/screenshots/style-streets-v2-light.png +0 -0
  134. package/docsmd/images/screenshots/style-streets-v2.png +0 -0
  135. package/docsmd/images/screenshots/style-toner.png +0 -0
  136. package/docsmd/images/screenshots/style-topo.png +0 -0
  137. package/docsmd/images/screenshots/style-topographique.png +0 -0
  138. package/docsmd/images/screenshots/style-voyager.png +0 -0
  139. package/docsmd/images/screenshots/style-winter.png +0 -0
  140. package/images/JS-logo.svg +4 -0
  141. package/images/TS-logo.svg +6 -0
  142. package/images/maptiler-logo.svg +19 -0
  143. package/images/maptiler-sdk-logo.afdesign +0 -0
  144. package/images/maptiler-sdk-logo.svg +66 -0
  145. package/images/screenshots/alps.gif +0 -0
  146. package/images/screenshots/grandcanyon.gif +0 -0
  147. package/images/screenshots/lang-arabic.png +0 -0
  148. package/images/screenshots/lang-hebrew.png +0 -0
  149. package/images/screenshots/multilang.gif +0 -0
  150. package/images/screenshots/static-bounded-europe-1024.png +0 -0
  151. package/images/screenshots/static-bounded-europe-2048.png +0 -0
  152. package/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  153. package/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  154. package/images/screenshots/static-with-path.png +0 -0
  155. package/images/screenshots/style-basic-v2.png +0 -0
  156. package/images/screenshots/style-bright.png +0 -0
  157. package/images/screenshots/style-dataviz-dark.png +0 -0
  158. package/images/screenshots/style-hybrid.png +0 -0
  159. package/images/screenshots/style-osm.png +0 -0
  160. package/images/screenshots/style-outdoor.png +0 -0
  161. package/images/screenshots/style-pastel.png +0 -0
  162. package/images/screenshots/style-satellite.png +0 -0
  163. package/images/screenshots/style-streets-v2-dark.png +0 -0
  164. package/images/screenshots/style-streets-v2-light.png +0 -0
  165. package/images/screenshots/style-streets-v2.png +0 -0
  166. package/images/screenshots/style-toner.png +0 -0
  167. package/images/screenshots/style-topo.png +0 -0
  168. package/images/screenshots/style-topographique.png +0 -0
  169. package/images/screenshots/style-voyager.png +0 -0
  170. package/images/screenshots/style-winter.png +0 -0
  171. package/package.json +71 -0
  172. package/readme.md +609 -0
  173. package/rollup.config.js +161 -0
  174. package/scripts/replace-path-with-content.js +51 -0
  175. package/src/CustomGeolocateControl.ts +193 -0
  176. package/src/CustomLogoControl.ts +59 -0
  177. package/src/Map.ts +897 -0
  178. package/src/MaptilerNavigationControl.ts +66 -0
  179. package/src/Point.ts +336 -0
  180. package/src/TerrainControl.ts +87 -0
  181. package/src/config.ts +92 -0
  182. package/src/defaults.ts +20 -0
  183. package/src/index.ts +171 -0
  184. package/src/language.ts +139 -0
  185. package/src/mapstyle.ts +38 -0
  186. package/src/style/style_template.css +146 -0
  187. package/src/style/svg/v6-compass.svg +12 -0
  188. package/src/style/svg/v6-fullscreen-off.svg +7 -0
  189. package/src/style/svg/v6-fullscreen.svg +7 -0
  190. package/src/style/svg/v6-geolocate-active-error.svg +10 -0
  191. package/src/style/svg/v6-geolocate-active.svg +7 -0
  192. package/src/style/svg/v6-geolocate-background.svg +8 -0
  193. package/src/style/svg/v6-geolocate-disabled.svg +10 -0
  194. package/src/style/svg/v6-geolocate.svg +7 -0
  195. package/src/style/svg/v6-terrain-on.svg +7 -0
  196. package/src/style/svg/v6-terrain.svg +7 -0
  197. package/src/style/svg/v6-zoom-minus.svg +7 -0
  198. package/src/style/svg/v6-zoom-plus.svg +7 -0
  199. package/src/tools.ts +45 -0
  200. package/src/unit.ts +1 -0
  201. package/tsconfig.json +11 -0
  202. package/typedoc.css +118 -0
  203. package/typedoc.json +13 -0
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@maptiler/sdk",
3
+ "version": "1.0.0",
4
+ "description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
5
+ "module": "dist/maptiler-sdk.mjs",
6
+ "types": "dist/maptiler-sdk.d.ts",
7
+ "style": "dist/maptiler-sdk.css",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/maptiler-sdk.mjs"
12
+ },
13
+ "./dist/maptiler-sdk.css": {
14
+ "import": "./dist/maptiler-sdk.css"
15
+ }
16
+ },
17
+ "keywords": [
18
+ "maptiler",
19
+ "map",
20
+ "sdk",
21
+ "webmap",
22
+ "cloud",
23
+ "webGL"
24
+ ],
25
+ "homepage": "https://www.maptiler.com/cloud/",
26
+ "license": "BSD-3-Clause",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/maptiler/maptiler-sdk-js.git"
30
+ },
31
+ "scripts": {
32
+ "build": "rm -rf dist/* ; NODE_ENV=production rollup -c",
33
+ "dev": "rm -rf dist/* ; NODE_ENV=development rollup -c -w",
34
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
35
+ "lint": "eslint --fix \"src/**/*.{js,ts}\"",
36
+ "docmd": "rm -rf docsmd/*; typedoc --readme none --plugin typedoc-plugin-markdown --out docsmd src/index.ts; cp -r images docsmd/",
37
+ "dochtml": "rm -rf docs/*; typedoc --plugin none --out docs; cp -r images docs/",
38
+ "doc": "npm run docmd; npm run dochtml",
39
+ "prepare": "npm run format; npm run lint; npm run build; npm run doc; cp -r demos docs/"
40
+ },
41
+ "author": "MapTiler",
42
+ "devDependencies": {
43
+ "@rollup/plugin-commonjs": "^22.0.2",
44
+ "@rollup/plugin-json": "^5.0.1",
45
+ "@rollup/plugin-node-resolve": "^14.1.0",
46
+ "@typescript-eslint/eslint-plugin": "^5.41.0",
47
+ "@typescript-eslint/parser": "^5.41.0",
48
+ "eslint": "^8.26.0",
49
+ "prettier": "^2.7.1",
50
+ "rollup": "^2.79.0",
51
+ "rollup-plugin-copy-merge": "^0.3.5",
52
+ "rollup-plugin-dts": "^4.2.2",
53
+ "rollup-plugin-esbuild": "^4.10.1",
54
+ "rollup-plugin-node-globals": "^1.4.0",
55
+ "rollup-plugin-shell": "^1.0.9",
56
+ "rollup-plugin-string": "^3.0.0",
57
+ "rollup-plugin-swc": "^0.2.1",
58
+ "serve": "^14.0.1",
59
+ "terser": "^5.15.0",
60
+ "typedoc": "^0.23.21",
61
+ "typedoc-plugin-markdown": "^3.13.6",
62
+ "typescript": "^4.8.4"
63
+ },
64
+ "dependencies": {
65
+ "@maptiler/client": "^1.1.3",
66
+ "events": "^3.3.0",
67
+ "js-base64": "^3.7.4",
68
+ "maplibre-gl": "^3.0.0-pre.3",
69
+ "uuid": "^9.0.0"
70
+ }
71
+ }
package/readme.md ADDED
@@ -0,0 +1,609 @@
1
+
2
+ <p align="center">
3
+ <img src="images/maptiler-sdk-logo.svg" width="400px">
4
+ </p>
5
+
6
+ <p align="center" style="color: #AAA">
7
+ The Javascript & TypeScript map SDK tailored for <a href="https://www.maptiler.com/cloud/">MapTiler Cloud</a>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <img src="images/JS-logo.svg" width="20px">
12
+ <img src="images/TS-logo.svg" width="20px">
13
+ <img src="https://img.shields.io/npm/v/@maptiler/sdk"></img>
14
+ <img src="https://img.shields.io/twitter/follow/maptiler?style=social"></img>
15
+ </p>
16
+
17
+ # What and why?
18
+ The **MapTiler SDK JS** extends MapLibre GL JS, exposes all its features, and adds new ones on top. The SDK is designed to work with the well-established [MapTiler Cloud service](https://www.maptiler.com/cloud/), which provides all the data required to fuel a complete web mapping experience: vector tiles, satellite raster tiles, DEM with Terrain RGB, custom styles with an editor, etc.
19
+
20
+ **Why are we creating a new SDK?** To make things simpler for developers working in the MapTiler ecosystem! With **MapTiler SDK JS**, there is no need to load external plugins for the most basic things, copy-paste complex data source URLs, or look up the syntax to enable 3D terrain every time you start a project. All this is built-in, loaded when needed, or exposed with simple functions. Under the hood, this SDK is opinionated as it's being fed by [MapTiler Cloud](https://www.maptiler.com/cloud/) data, but its MapLibre core makes it 100% compatible with other sources.
21
+
22
+ In addition, the MapTiler SDK JS provides well-documented and easy-to-use wrapper functions to the [MapTiler Cloud API services](https://docs.maptiler.com/cloud/api) such as: geocoding, static maps, geolocation, as well as a search engine for coordinate reference systems and transforming coordinates from one CRS to another.
23
+ > 📣 *__Note:__* If you need <ins>only the API Client library</ins> to use in a headless fashion and without any map display, check out [MapTiler Client JS](https://github.com/maptiler/maptiler-client-js) library for browser and NodeJS.
24
+
25
+ # Install
26
+ ```shell
27
+ npm install --save @maptiler/sdk
28
+ ```
29
+
30
+ # API documentation
31
+ In addition to the details and examples provided in this readme, check out the [complete API documentation](https://maptiler.github.io/maptiler-sdk-js) (see the [Markdown version](docsmd/README.md))
32
+
33
+ # Quick start
34
+
35
+ ## With ES modules
36
+ **Recommended for:** advanced applications
37
+
38
+ ```ts
39
+ import * as maptilersdk from '@maptiler/sdk';
40
+
41
+ // Add your MapTiler Cloud API key to the config
42
+ // (Go to https://cloud.maptiler.com/account/keys/ to get one for free!)
43
+ maptilersdk.config.apiKey = 'YOUR_API_KEY';
44
+
45
+ // Let's say you have a DIV ready to receive a map
46
+ const mapContainer = document.getElementById('my-container-div');
47
+
48
+ // Instanciate the map
49
+ const map = new maptilersdk.Map({
50
+ container: mapContainer,
51
+ });
52
+ ```
53
+ By default, the map will be initialized with the style [streets-v2](https://www.maptiler.com/maps/#style=streets-v2).
54
+
55
+ Depending on the framework and environment your are using for your application, you will have to also include the CSS file.
56
+
57
+ For example, with a [NextJS](https://nextjs.org/) app, this can take place at the top of the file `_app.ts/js`:
58
+ ```ts
59
+ import "@maptiler/sdk/dist/maptiler-sdk.css";
60
+ ```
61
+
62
+
63
+ ## With CDN
64
+ The SDK hosted on our CDN is bundled as *[Universal Module Definition](https://github.com/umdjs/umd)* (UMD) to make it standalone and containing all its dependencies. The CDN also serves the style sheet (css).
65
+
66
+ **Recommended for:** simple map intergration example and demos
67
+
68
+ ```html
69
+ <html>
70
+ <head>
71
+ <title>MapTiler JS SDK example</title>
72
+ <style>
73
+ html, body {
74
+ margin: 0;
75
+ }
76
+
77
+ #map-container {
78
+ position: absolute;
79
+ width: 100vw;
80
+ height: 100vh;
81
+ }
82
+ </style>
83
+
84
+ <!-- Load the SDK CSS -->
85
+ <link rel="stylesheet" href="dist/maptiler-sdk.css">
86
+ </head>
87
+
88
+ <body>
89
+ <div id="map-container"></div>
90
+
91
+ <script src ="dist/maptiler-sdk.umd.js"></script>
92
+
93
+ <script>
94
+ // Add your MapTiler Cloud API key to the config
95
+ // (Go to https://cloud.maptiler.com/account/keys/ to get one for free!)
96
+ maptilersdk.config.apiKey = 'YOUR_API_KEY';
97
+
98
+ const mapContainer = document.getElementById('my-container-div');
99
+
100
+ const map = new maptilersdk.Map({
101
+ container: mapContainer,
102
+ style: maptilersdk.MapStyle.STREETS_DARK,
103
+ hash: true,
104
+ })
105
+ </script>
106
+ </body>
107
+ </html>
108
+ ```
109
+ Checkout the minimalist code samples in the [demos](demos) directory.
110
+
111
+
112
+ # Many styles to choose from
113
+ MapTiler teams maintains a few styles that we have decided to expose from the SDK. This has two advantages:
114
+ - they are easier to remember, no need to type along style URL
115
+ - if we make an update to a style, you will benefit from it without modifying your codebase
116
+
117
+ Here is how it works:
118
+ ```ts
119
+ import { Map, MapStyle } from '@maptiler/sdk'
120
+
121
+ // When instanciating a map
122
+ const map = new Map({
123
+ container: document.getElementById("my-container-div"),
124
+ style: MapStyle.OUTDOOR, // <-- the shorthand for the outdoor style
125
+ });
126
+
127
+ // Or later on, updating the style
128
+ map.setStyle(MapStyle.STREETS.DARK);
129
+ ```
130
+
131
+ The styles with a shorthand provided by the SDK are the following:
132
+
133
+ | ID | Screenshot | Comment |
134
+ |:-:|:-:|:-:|
135
+ |`MapStyle.STREETS`|[![](images/screenshots/style-streets-v2.png)](https://www.maptiler.com/maps/#style=streets-v2&mode=2d&position=12.52/40.73676/-73.98418)|The classic default style, perfect for urban areas.<p>Also available in **dark** and **light** mode.</p>|
136
+ |`MapStyle.DATAVIZ.DARK`| [![](images/screenshots/style-dataviz-dark.png)](https://www.maptiler.com/maps/#style=dataviz-dark&mode=2d&position=2.01/38.7/-27.0)|A minimalist style for data visualization.<p>Also available in **color** and **light** mode</p> |
137
+ |`MapStyle.SATELLITE`|[![](images/screenshots/style-satellite.png)](https://www.maptiler.com/maps/#style=hybrid&mode=2d&position=7.87/24.518/-77.411)|Only high resolution satellite raster tiles without any labels|
138
+ |`MapStyle.HYBRID`|[![](images/screenshots/style-hybrid.png)](https://www.maptiler.com/maps/#style=hybrid&mode=2d&position=9.4/-26.175/122.6631)|Satellite tile with labels, landmarks, roads ways and political borders|
139
+ |`MapStyle.OUTDOOR`|[![](images/screenshots/style-outdoor.png)](https://www.maptiler.com/maps/#style=outdoor&mode=2d&position=11.96/46.02591/7.7273)|A solid hiking companion, with peaks, parks, isolines and more|
140
+ |`MapStyle.BASIC`|[![](images/screenshots/style-basic-v2.png)](https://www.maptiler.com/maps/#style=basic-v2&mode=2d&position=13.09/37.78734/-122.42025)|A minimalist alternative to `STREETS`, with a touch of flat design.<p>Also available in **dark** and **light** and **pastel** mode.</p>|
141
+
142
+
143
+ <details>
144
+ <summary>Know more about built-in map styles</summary>
145
+
146
+ MapTiler provides some **reference styles** as well as some **variants** for each. A **reference syle** sets some guidelines about what kind of information is displayed, the granularity of the information, and more generaly defines a purpose for which this style is the most relevant: street navigation, outdoor adventure, minimalist dashboard, etc. Then, each **reference style** offers a range of **variants** that contain the same level of information and has the same purpose but using different colors schemes.
147
+
148
+ Here is the full list:
149
+ - `MapStyle.STREETS`, reference style for navigation and city exploration
150
+ - `MapStyle.STREETS.DARK` (variant)
151
+ - `MapStyle.STREETS.LIGHT` (variant)
152
+ - `MapStyle.STREETS.PASTEL` (variant)
153
+ - `MapStyle.OUTDOOR` reference style for adventure
154
+ - `MapStyle.WINTER` reference style for winter adventure
155
+ - `MapStyle.SATELLITE` reference style satellite and airborne imagery (no variants)
156
+ - `MapStyle.HYBRID` reference style satellite and airborne imagery with labels (no variants)
157
+ - `MapStyle.BASIC` reference style for minimalist design and general purpose
158
+ - `MapStyle.BASIC.DARK` (variant)
159
+ - `MapStyle.BASIC.LIGHT` (variant)
160
+ - `MapStyle.BRIGHT` reference style for high contrast navigation
161
+ - `MapStyle.BRIGHT.DARK` (variant)
162
+ - `MapStyle.BRIGHT.LIGHT` (variant)
163
+ - `MapStyle.BRIGHT.PASTEL` (variant)
164
+ - `MapStyle.TOPO` reference style for topographic study
165
+ - `MapStyle.TOPO.SHINY` (variant)
166
+ - `MapStyle.TOPO.PASTEL` (variant)
167
+ - `MapStyle.TOPO.TOPOGRAPHIQUE` (variant)
168
+ - `MapStyle.VOYAGER` reference style for stylish yet minimalist maps
169
+ - `MapStyle.VOYAGER.DARK` (variant)
170
+ - `MapStyle.VOYAGER.LIGHT` (variant)
171
+ - `MapStyle.VOYAGER.VINTAGE` (variant)
172
+ - `MapStyle.TONER` reference style for very high contrast stylish maps
173
+ - `MapStyle.TONER.BACKGROUND` (variant)
174
+ - `MapStyle.TONER.LITE` (variant)
175
+ - `MapStyle.TONER.LINES` (variant)
176
+ - `MapStyle.OPENSTREETMAP` (reference style, this one does not have any variants)
177
+ - `MapStyle.DATAVIZ`, the perfect style for data visualization, with very little noise
178
+ - `MapStyle.DATAVIZ.DARK` (variant)
179
+ - `MapStyle.DATAVIZ.LIGHT` (variant)
180
+
181
+ All reference styles (instances of `ReferenceMapStyle`) and style variants (instances of `MapStyleVariant`) have methods to know the alternative styles and variant that belong to the same reference style (`.getVariants()`). This is handy to provide a default/dark/light alternative color scheme, yet preserving the same level of details as in the reference style. Read more about about [ReferenceMapStyle](docsmd/classes/ReferenceMapStyle.md) and [MapStyleVariant](docsmd/classes/MapStyleVariant.md).
182
+ </details>
183
+
184
+ ___
185
+
186
+
187
+ Still, you can still use some classic styles with just a *string* if you know their MapTiler CLoud ID:
188
+
189
+ ```ts
190
+ map.setStyle('outdoor-v2');
191
+ ```
192
+
193
+ And finally, you can use your own custom styles designed with [our style editor](https://cloud.maptiler.com/maps/). Every custom style is given a unique ID, for instance: `c912ffc8-2360-487a-973b-59d037fb15b8`.
194
+
195
+ This ID can be provided as such:
196
+ ```ts
197
+ map.setStyle("c912ffc8-2360-487a-973b-59d037fb15b8");
198
+ ```
199
+
200
+ Or in its extended form:
201
+ ```ts
202
+ map.setStyle("https://api.maptiler.com/maps/c912ffc8-2360-487a-973b-59d037fb15b8/style.json");
203
+ // this could be suffixed with the API token as well
204
+ ```
205
+
206
+ And can even be provided in the URI form:
207
+ ```ts
208
+ map.setStyle("maptiler://c912ffc8-2360-487a-973b-59d037fb15b8");
209
+ ```
210
+
211
+ # Centering the map on visitors
212
+ It is sometimes handy to center map on the visitor's location, and there are multiple ways of doing it but for the SDK, we have decided to make this extra simple by using the [IP geolocation](#%EF%B8%8F%EF%B8%8F-geolocation) API provided by [MapTiler Cloud](https://docs.maptiler.com/cloud/api/geolocation/), directly exposed as a single option of the `Map` constructor. There are two strategies:
213
+ 1. `POINT`: centering the map on the actual visitor location, optionnaly using the `zoom` option (zoom level `13` if none is provided). As a more precise option, if the user has previously granted access to the browser location (more precise) then this is going to be used.
214
+ 2. `COUNTRY`: fitting the map view on the bounding box of the visitor's country. In this case, the `zoom` option, if provided, will be ignored
215
+
216
+ Here is how the map gets centered on the visitor's location:
217
+ ```js
218
+ new maptiler.Map({
219
+ // ... other options
220
+
221
+ geolocate: maptiler.GeolocationType.POINT
222
+ })
223
+ ```
224
+
225
+ Here is how the map fits the visitor's country bounds:
226
+ ```js
227
+ new maptiler.Map({
228
+ // ... other options
229
+
230
+ geolocate: maptiler.GeolocationType.COUNTRY
231
+ })
232
+ ```
233
+
234
+ The `geolocation` options will not be taken into consideration in the following cases:
235
+ - if the `center` options is provided, then it prevails
236
+ - if the `hash` options is provided with the value `true` **AND** a location hash is already part of the URL. If `hash` is `true` but there is not yet a location hash in the URL, then the geolocation will work.
237
+
238
+ > 📣 *__Note:__* if none of the options `center` or `hash` is provided to the `Map` constructor, then the map will be centered using the `POINT` strategy, unless the `geolocate` has the value `false`.
239
+
240
+ > 📣 *__Note 2:__* the term *IP geolocation* refers to finding the physical location of a computer using its *IP address*. The *IP address* is a numerical identifier of a computer within a network, just like the phone number for a telephone. The *IP geolocation* is **not** using the GPS of a device and usually provides a precision in the order of a few hundred meters. This precision may vary based on many local parameters such as the density of the network grid or the terrain, this is why it is generaly better not to use a zoom level higher than `14`.
241
+
242
+ # Easy to add controls
243
+ The term "control" is commonly used for all sorts of buttons and information display that take place in one of the corner of the map area. The most well know are probably the `[+]` and `[-]` zoom buttons as well as the attribution information. Plenty of others are possible and we have made a few easy to add and directly accessible from the `Map` constructor options:
244
+
245
+ - `navigationControl`
246
+ - Shows the `[+]`, `[-]` and tilt/bearing/compass buttons
247
+ - a boolean or a corner position. Showing on the top-right by default. Hidden if `false`.
248
+ - `geolocateControl`
249
+ - Shows a arrow-shaped locate button. When clicked, it adds a marker and center the map. If clicked again, the marker disapears (unless the map was moved since first clicked)
250
+ - a boolean or a corner position. Showing on the top-right by default. Hidden if `false`.
251
+ - `terrainControl`
252
+ - Shows a button to enable/disable the 3D terrain (does not tilt the map)
253
+ - a boolean or a corner position. Hidden by default, showing on top-right if `true`.
254
+ - `scaleControl`
255
+ - Shows a distance scale. The unit (`"metric"`, `"imperial"` or `"nautical"`) can be set in the config object `config.unit` (default: `"metric"`)
256
+ - a boolean or a corner position. Hidden by default, showing on bottom-right if `true`.
257
+ - `fullscreenControl`
258
+ - Shows a button that toggles the map into fullscreen
259
+ - a boolean or a corner position. Hidden by default, showing on top-right if `true`.
260
+
261
+ The corner positions possible are:
262
+ - `"top-left"`
263
+ - `"top-right"`
264
+ - `"bottom-left"`
265
+ - `"bottom-right"`
266
+
267
+ **Example:**
268
+ ```ts
269
+ import { Map } from "@maptiler/sdk";
270
+
271
+ const map = new Map({
272
+ container: document.getElementById("my-container-div"),
273
+ terrainControl: false,
274
+ scaleControl: true,
275
+ fullscreenControl: "top-left",
276
+ })
277
+ ```
278
+
279
+
280
+
281
+ # 3D terrain in one call
282
+ <p align="center">
283
+ <img src="images/screenshots/grandcanyon.gif" width="48%"></img>
284
+ <img src="images/screenshots/alps.gif" width="48%"></img>
285
+ </p>
286
+
287
+
288
+ You want to enable 3D terrain? That's easy now with a single function call:
289
+ ```ts
290
+ // With the default exaggeration factor of 1
291
+ map.enableTerrain();
292
+
293
+ // Or, if you want to boost some volume a little
294
+ map.enableTerrain(1.5);
295
+ ```
296
+
297
+ The terrain can also be enabled directly from the `Map` constructor, with the options `terrain` (a boolean, `false` by default) and `terrainExaggeration` (a number, `1` by default):
298
+
299
+ ```ts
300
+ const map = new Map({
301
+ // some options...
302
+ terrain: true,
303
+ terrainExaggeration: 1.5,
304
+ })
305
+ ```
306
+
307
+ At any point, you can modify the exaggeration factor:
308
+ ```ts
309
+ map.setTerrainExaggeration(2);
310
+ ```
311
+
312
+ Or simply disable it:
313
+ ```ts
314
+ map.disableTerrain()
315
+ ```
316
+
317
+ > 📣 *__Note:__* Keep in mind that setting an exaggeration factor at `0` will result in a the same result as disabling the elevation but that terrain RGB tiles will still be fetched in the background.
318
+
319
+ > 📣 *__Note 2:__* please be aware that due to the volume and elevation of the map floor in 3D space, the navigation with the terrain enabled is slightly different than without.
320
+
321
+
322
+ # Easy language switching
323
+ The language generally depends on the style but we made it possible to easily update it with a single function and from a built-in list of languages:
324
+
325
+ ```ts
326
+ map.setLanguage(maptilersdk.Language.ENGLISH);
327
+ ```
328
+
329
+ The list of supported languages is built-in and can be found [here](src/language.ts). In addition, there are spacial language *flags*:
330
+ - `maptilersdk.Language.AUTO` **[DEFAULT]** uses the language defined in the web browser
331
+ - `maptilersdk.Language.LOCAL` uses the language local to each country
332
+ - `maptilersdk.Language.LATIN` uses a default with latin characters
333
+ - `maptilersdk.Language.NON_LATIN` uses a default with non-latin characters
334
+
335
+ Whenever a label is not supported in the defined language, it falls back to `maptilersdk.Language.LATIN`.
336
+
337
+ Here is a sample of some compatible languages:
338
+ ![](images/screenshots/multilang.gif)
339
+
340
+ # Built-in support for right-to-left languages
341
+ Languages that are written right-to-left such as arabic and hebrew are fully supported by default. No need to install any plugin!
342
+
343
+ <p align="center">
344
+ <img src="images/screenshots/lang-arabic.png" width="48%"></img>
345
+ <img src="images/screenshots/lang-hebrew.png" width="48%"></img>
346
+ </p>
347
+
348
+ # Easy access to MapTiler Cloud API
349
+ Our map SDK is not only about maps! We also provide plenty of wrapper to our API calls!
350
+
351
+ > 📣 *__Note:__* If you need <ins>only the API Client library</ins> to use in a headless fashion and without any map display, check out out [API Client library](https://docs.maptiler.com/client-js/) for browser and NodeJS. It's exactely what is down below and only that, in a minimalistic [TypeScript package](https://github.com/maptiler/maptiler-client-js) 🐙.
352
+
353
+
354
+ ## 🔍 Geocoding
355
+ > ✅ Please, use geocoding functions only from client-side (browser) and do not 🚫 **store** or **redistribute** MapTiler Cloud API data. In case of doubt, consult the [terms](https://www.maptiler.com/cloud/terms/#explicitly-prohibited-use) ⚖️
356
+
357
+ ### Forward
358
+ You want to know the longitude and latitude of a specific place, use the forward geocoding:
359
+ ```ts
360
+ // in an async function, or as a 'thenable':
361
+ const result = await maptilerClient.geocoding.forward('paris');
362
+ ```
363
+ You can provide some options such as:
364
+ - the proximity, given a lon-lat position, to sort the results
365
+ - one of more languages to get the results into
366
+ - a bounding geo box, to restrict the search to a given window
367
+
368
+ Read more about forward geocoding on our [official documentation](https://docs.maptiler.com/client-js/geocoding/#forward).
369
+
370
+ ### Reverse
371
+ You wan to tknow the name of a place, given a longitude-latitude? Use the reverse geocoding:
372
+ ```ts
373
+ // in an async function, or as a 'thenable':
374
+ const result = await maptilerClient.geocoding.reverse([6.249638, 46.402056]);
375
+ ```
376
+ The same option object as the forward geocoding can be provided.
377
+
378
+ Read more about reverse geocoding on our [official documentation](https://docs.maptiler.com/client-js/geocoding/#reverse).
379
+
380
+ ### Language
381
+ For both *forward* and *reverse* geocoding, this library provides a list of supported languages as shorthands to [ISO language codes](https://en.wikipedia.org/wiki/ISO_639-1). The result will be provided in multiple languages if the `language` options is an array:
382
+
383
+ ```ts
384
+ const result = await maptilerClient.geocoding.forward('paris', {language: [maptilerClient.geocoding.languages.SPANISH, maptilerClient.geocoding.languages.KOREAN]})
385
+ ```
386
+
387
+ The special language `AUTO` will detect the platform/browser preferred language.
388
+
389
+ ## 🕵️‍♂️ Geolocation
390
+ The geolocation service provides location informations of a visitor using its IP address.
391
+
392
+ The geolocation uses the IP address of a visitors to provide informations about their location, such as city, region, country, timezone, etc. The precision is lower than GPS but does not require visitors to explicitely enable the location service from their web browser.
393
+
394
+ There is only a single function:
395
+ ```ts
396
+ // in an async function, or as a 'thenable':
397
+ const result = await maptilerClient.geolocation.info();
398
+ ```
399
+
400
+ Read more about geolocation on our [official documentation](https://docs.maptiler.com/client-js/geolocation/).
401
+
402
+ ## 🌐 Coordinates
403
+ If you are already familiar with [epsg.io](https://epsg.io/) (created by MapTiler), then you may find convenient to access the details of more than 10 thousands of coordinate reference systems (CRS) programmatically, as well as transforming coordinates from one system to another!
404
+
405
+ ### Search
406
+ The `search` lets you perform a query in a free form fashion. Here are some examples:
407
+ ```ts
408
+ // in an async function, or as a 'thenable':
409
+ const resultA = await maptilerClient.coordinates.search('mercator');
410
+ const resultB = await maptilerClient.coordinates.search('plate carree');
411
+ const resultC = await maptilerClient.coordinates.search('france');
412
+ const resultD = await maptilerClient.coordinates.search('code:4326', {transformations: true}));
413
+ ```
414
+
415
+ The `transformations` options retrieves a lot more details about the CRS that MapTiler API is able to transform to/from than just their IDs.
416
+
417
+ Read more about searching coordinate systems on our [official documentation](https://docs.maptiler.com/client-js/coordinates/#search).
418
+
419
+ ### Transform
420
+ Transforming a couple of coordinates from one system to another can be challenging, for example, most countries have their own official system, yet web mapping tools are more often than not exclusive to [WGS84](https://epsg.io/4326).
421
+
422
+ If not provided, both the source (`sourceCrs`) and the destination (`targetCrs`) are default to **EPSG:4326** (in other words, [WGS84](https://epsg.io/4326)). Here is how to use this feature:
423
+
424
+ ```ts
425
+ // in an async function, or as a 'thenable':
426
+
427
+ // Providing one coordinate to transform, with a target CRS being EPSG:9793 (RGF93 v2 / Lambert-93, France official CRS)
428
+ const resultA = await maptilerClient.coordinates.transform([1, 45], {targetCrs: 9793})
429
+
430
+ // Using the same logic, we can pass up to 50 coordinates to be transformed
431
+ const resultB = await maptilerClient.coordinates.transform([[10, 48], [1, 45]], {targetCrs: 9793})
432
+ ```
433
+
434
+ Read more about transforming coordinates on our [official documentation](https://docs.maptiler.com/client-js/coordinates/#transform).
435
+
436
+ ## 💽 Data
437
+ MapTiler Cloud give its users the possibility to [upload and create data](https://cloud.maptiler.com/data/), manually with a user interface or by uploading a GPX, GeoJSON, KML or shp file. A unique ID is associated to each dataset so that we can later on access it programmatically to retrieve a GeoJSON equivalent of it:
438
+
439
+ ```ts
440
+ // in an async function, or as a 'thenable':
441
+ const result = await maptilerClient.data.get('my-dataset-unique-id')
442
+ ```
443
+
444
+ Since the result is a GeoJSON, it can easily be added to a `map` with `.addSource()` and `.addLayer()`.
445
+
446
+ Read more about fetching your own data on our [official documentation](https://docs.maptiler.com/client-js/data/).
447
+
448
+ ## 🗺️ Static maps
449
+ > ✅ Please, use static maps URLs only from client side `<img>` elements, and do not 🚫 store or redistribute the static map files. In case of doubt, consult the [terms](https://www.maptiler.com/cloud/terms/#explicitly-prohibited-use) ⚖️
450
+
451
+ Maptiler Cloud provides many possibilities for creating static maps as PNG, JPEG or WebP images. They all offer the possibilities to:
452
+ - Choose from one of the MapTiler style or your own
453
+ - Add markers with a custom icon (or default icon with custom color)
454
+ - Add path or polygon, with a parametric line width and color and a parametric filling color
455
+
456
+ Three modes are available: `centered`, `bounded` and `automatic`.
457
+
458
+ > 📣 *__important:__* <span style="text-decoration: underline">only image **URLs** are returned.</span>
459
+ > Contrary to the other functions of this library, the static map functions **do not** perform any query to MapTiler Cloud API, instead they build the image URL for you to use in `<img>` elements.
460
+
461
+
462
+ ### Map Styles
463
+ In the following static map functions, the `option` object features a `style` property that can be a string or one of the built-in style shorthand. Here is the full list:
464
+
465
+ - `MapStyle.STREETS`, reference style for navigation and city exploration
466
+ - `MapStyle.STREETS.DARK` (variant)
467
+ - `MapStyle.STREETS.LIGHT` (variant)
468
+ - `MapStyle.STREETS.PASTEL` (variant)
469
+ - `MapStyle.OUTDOOR` reference style for adventure
470
+ - `MapStyle.WINTER` reference style for winter adventure
471
+ - `MapStyle.SATELLITE` reference style satellite and airborne imagery (no variants)
472
+ - `MapStyle.HYBRID` reference style satellite and airborne imagery with labels (no variants)
473
+ - `MapStyle.BASIC` reference style for minimalist design and general purpose
474
+ - `MapStyle.BASIC.DARK` (variant)
475
+ - `MapStyle.BASIC.LIGHT` (variant)
476
+ - `MapStyle.BRIGHT` reference style for high contrast navigation
477
+ - `MapStyle.BRIGHT.DARK` (variant)
478
+ - `MapStyle.BRIGHT.LIGHT` (variant)
479
+ - `MapStyle.BRIGHT.PASTEL` (variant)
480
+ - `MapStyle.TOPO` reference style for topographic study
481
+ - `MapStyle.TOPO.SHINY` (variant)
482
+ - `MapStyle.TOPO.PASTEL` (variant)
483
+ - `MapStyle.TOPO.TOPOGRAPHIQUE` (variant)
484
+ - `MapStyle.VOYAGER` reference style for stylish yet minimalist maps
485
+ - `MapStyle.VOYAGER.DARK` (variant)
486
+ - `MapStyle.VOYAGER.LIGHT` (variant)
487
+ - `MapStyle.VOYAGER.VINTAGE` (variant)
488
+ - `MapStyle.TONER` reference style for very high contrast stylish maps
489
+ - `MapStyle.TONER.BACKGROUND` (variant)
490
+ - `MapStyle.TONER.LITE` (variant)
491
+ - `MapStyle.TONER.LINES` (variant)
492
+ - `MapStyle.OPENSTREETMAP` (reference style, this one does not have any variants)
493
+ - `MapStyle.STAGE`, the perfect style for data visualization, with very little noise
494
+ - `MapStyle.STAGE.DARK` (variant)
495
+ - `MapStyle.STAGE.LIGHT` (variant)
496
+
497
+ ### Centered static maps
498
+ This type of map is centered on a longitude-latitude coordinate and the zoom level must also be provided (from `0`: very zoomed out, to `22`: very zoomed in).
499
+ Note that if a path or markers are provided, the framing of the map will not automatically adapt to include those (use the `automatic` mode for that).
500
+
501
+ ```ts
502
+ const imageLink = maptilerClient.staticMaps.centered(
503
+ // center position (Boston)
504
+ [-71.06080, 42.362114],
505
+
506
+ // zoom level
507
+ 12.5,
508
+
509
+ // Options
510
+ {
511
+ // Request a hiDPI/Retina image
512
+ hiDPI: true,
513
+
514
+ // Output image size
515
+ width: 1000,
516
+ height: 1000,
517
+
518
+ // Map style
519
+ style: maptilerClient.MapStyle.OUTDOOR,
520
+ });
521
+ ```
522
+
523
+ Read more about centered static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#center-based-image).
524
+
525
+
526
+ ### Bounded static maps
527
+ This type of map requires a bounding box made of two points: the south-west bound and the north-east bound. The zoom level cannot be provided and is automatically deduced from the size of the bounding box.
528
+
529
+ ```ts
530
+ const imageLink = maptilerClient.staticMaps.bounded(
531
+ // The bounding box on Europe
532
+ [
533
+ -24, // west bound (min x)
534
+ 34.5, // south bound (min y)
535
+ 32, // east bound (max x)
536
+ 71, // north bound (max y)
537
+ ],
538
+
539
+ // Options
540
+ {
541
+ hiDPI: true,
542
+ width: 2048,
543
+ height: 2048,
544
+ style: maptilerClient.MapStyle.STREETS.DARK,
545
+
546
+ // Extra space that will add around the bounding box, in percentage
547
+ // (0.1 = 10% is actually the dafault)
548
+ padding: 0.1
549
+ });
550
+ ```
551
+
552
+ Since the zoom level cannot be provided, the level of details is dictated by the size of the output image. here is an example:
553
+
554
+ | `2048 x 2048` | `1024 x 1024` |
555
+ | :-----------: | :-----------: |
556
+ | ![](images/screenshots/static-bounded-europe-2048.png) | ![](images/screenshots/static-bounded-europe-1024.png) |
557
+
558
+ As you may notice, the geo bounding box could have very different proportions than the output image size. In the following example, we place the very same bounding box around Portugal, which has a this particular strip looking shape. We also add a `path` that repeats exactly the same bounding box to show the difference between the provided bounding box and the final image. We kept the default padding of 10%:
559
+
560
+
561
+ | `2048 x 2048` | `1024 x 2048` |
562
+ | :-----------: | :-----------: |
563
+ | ![](images/screenshots/static-bounded-portugal-2048x2048.png) | ![](images/screenshots/static-bounded-portugal-1024x2048.png) |
564
+
565
+
566
+ Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#bounds-based-image).
567
+
568
+ ### Automatic static maps
569
+ As we have seen with centered and bounded maps, providing all the parameters is nice but can be cumbersome for the simplest use cases. This is why MapTiler Cloud also provides static maps that fits automatically whatever you need to place inside: path or markers.
570
+
571
+ In the following example, we are going to load a cycling track recorded by one of our team members in Montreal, Canada. The track, originally a GPX file, was pushed to MapTiler Data and is now made available as a GeoJSON:
572
+
573
+ ```ts
574
+ // Fetching the GeoJSON
575
+ const bikeTrack = await maptilerClient.data.get('the-id-of-a-bike-track-in-montreal');
576
+
577
+ // Extracting the track points with the shape [[lng, lat], [lng, lat], ...]
578
+ const trackPoints = bikeTrack.features[0].geometry.coordinates[0]
579
+ .map(p => p.slice(0, 2));
580
+
581
+ const imageLink = maptilerClient.staticMaps.automatic({
582
+ // hiDPI/Retina precision
583
+ hiDPI: true,
584
+
585
+ // A fairly large output image
586
+ width: 2048,
587
+ height: 1024 ,
588
+
589
+ // A grey style on which the track will pop!
590
+ style: maptilerClient.MapStyle.STREETS.LIGHT,
591
+
592
+ // Draw a path with the trackpoints
593
+ path: trackPoints,
594
+
595
+ // Adding a marker for the starting point, with a custom color (array of shape [lng, lat, color])
596
+ marker: [trackPoints[0][0], trackPoints[0][1], '#0a0'],
597
+
598
+ // Showing the track in red
599
+ pathStrokeColor: 'red',
600
+ });
601
+ ```
602
+
603
+ And voila!
604
+
605
+ ![static map with bike path](images/screenshots/static-with-path.png)
606
+
607
+ > 📣 *__Note:__* The GeoJSON for this track contains 9380 couples of coordinates, which is a lot! In order to send the track to MapTiler Cloud static maps API, the client simplifies the long paths while keeping a high degree of precision using a very fast [Ramer-Douglas-Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm).
608
+
609
+ Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#auto-fitted-image).