@maptiler/client 1.6.0 → 1.8.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 (118) hide show
  1. package/.github/pull_request_template.md +11 -0
  2. package/.github/workflows/format-lint.yml +24 -0
  3. package/CHANGELOG.md +25 -0
  4. package/dist/maptiler-client.cjs +587 -332
  5. package/dist/maptiler-client.cjs.map +1 -1
  6. package/dist/maptiler-client.d.ts +291 -12
  7. package/dist/maptiler-client.min.mjs +1 -1
  8. package/dist/maptiler-client.mjs +580 -332
  9. package/dist/maptiler-client.mjs.map +1 -1
  10. package/package.json +29 -20
  11. package/readme.md +134 -2
  12. package/rollup.config.js +3 -3
  13. package/tsconfig.json +1 -1
  14. package/dist/maptiler-client.umd.js +0 -1368
  15. package/dist/maptiler-client.umd.js.map +0 -1
  16. package/dist/maptiler-client.umd.min.js +0 -1
  17. package/docs/.nojekyll +0 -1
  18. package/docs/assets/custom.css +0 -118
  19. package/docs/assets/highlight.css +0 -85
  20. package/docs/assets/main.js +0 -58
  21. package/docs/assets/search.js +0 -1
  22. package/docs/assets/style.css +0 -1280
  23. package/docs/classes/config.ClientConfig.html +0 -132
  24. package/docs/classes/services_ServiceError.ServiceError.html +0 -103
  25. package/docs/functions/language.getAutoLanguageGeocoding.html +0 -60
  26. package/docs/functions/services_simplify.default.html +0 -65
  27. package/docs/images/JS-logo.svg +0 -4
  28. package/docs/images/TS-logo.svg +0 -6
  29. package/docs/images/maptiler-client-logo.afdesign +0 -0
  30. package/docs/images/maptiler-client-logo.svg +0 -75
  31. package/docs/images/maptiler-logo-256.png +0 -0
  32. package/docs/images/maptiler-logo.svg +0 -23
  33. package/docs/images/screenshots/static-bounded-europe-1024.png +0 -0
  34. package/docs/images/screenshots/static-bounded-europe-2048.png +0 -0
  35. package/docs/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  36. package/docs/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  37. package/docs/images/screenshots/static-with-path.png +0 -0
  38. package/docs/index.html +0 -340
  39. package/docs/modules/config.html +0 -71
  40. package/docs/modules/language.html +0 -71
  41. package/docs/modules/services_ServiceError.html +0 -61
  42. package/docs/modules/services_coordinates.html +0 -84
  43. package/docs/modules/services_data.html +0 -66
  44. package/docs/modules/services_geocoding.html +0 -82
  45. package/docs/modules/services_geolocation.html +0 -68
  46. package/docs/modules/services_simplify.html +0 -61
  47. package/docs/modules/services_staticMaps.html +0 -74
  48. package/docs/modules.html +0 -59
  49. package/docs/types/config.FetchFunction.html +0 -71
  50. package/docs/types/language.LanguageGeocodingString.html +0 -58
  51. package/docs/types/services_coordinates.CoordinateExport.html +0 -71
  52. package/docs/types/services_coordinates.CoordinateGrid.html +0 -69
  53. package/docs/types/services_coordinates.CoordinateId.html +0 -71
  54. package/docs/types/services_coordinates.CoordinateSearch.html +0 -93
  55. package/docs/types/services_coordinates.CoordinateSearchResult.html +0 -75
  56. package/docs/types/services_coordinates.CoordinateTransformResult.html +0 -76
  57. package/docs/types/services_coordinates.CoordinateTransformation.html +0 -89
  58. package/docs/types/services_coordinates.CoordinatesSearchOptions.html +0 -83
  59. package/docs/types/services_coordinates.CoordinatesTransformOptions.html +0 -85
  60. package/docs/types/services_coordinates.XYZ.html +0 -73
  61. package/docs/types/services_data.GetDataOptions.html +0 -64
  62. package/docs/types/services_geocoding.ByIdGeocodingOptions.html +0 -63
  63. package/docs/types/services_geocoding.CommonForwardAndReverseGeocodingOptions.html +0 -63
  64. package/docs/types/services_geocoding.Coordinates.html +0 -63
  65. package/docs/types/services_geocoding.FeatureHierarchy.html +0 -63
  66. package/docs/types/services_geocoding.GeocodingFeature.html +0 -63
  67. package/docs/types/services_geocoding.GeocodingOptions.html +0 -63
  68. package/docs/types/services_geocoding.GeocodingSearchResult.html +0 -80
  69. package/docs/types/services_geocoding.LanguageGeocodingOptions.html +0 -70
  70. package/docs/types/services_geocoding.ReverseGeocodingOptions.html +0 -63
  71. package/docs/types/services_geolocation.GeolocationInfoOptions.html +0 -65
  72. package/docs/types/services_geolocation.GeolocationResult.html +0 -128
  73. package/docs/types/services_staticMaps.AutomaticStaticMapOptions.html +0 -61
  74. package/docs/types/services_staticMaps.BoundedStaticMapOptions.html +0 -61
  75. package/docs/types/services_staticMaps.CenteredStaticMapOptions.html +0 -61
  76. package/docs/types/services_staticMaps.StaticMapBaseOptions.html +0 -157
  77. package/docs/types/services_staticMaps.StaticMapMarker.html +0 -61
  78. package/docs/variables/config.config.html +0 -58
  79. package/docs/variables/language.LanguageGeocoding.html +0 -171
  80. package/docs/variables/services_coordinates.coordinates.html +0 -110
  81. package/docs/variables/services_data.data.html +0 -80
  82. package/docs/variables/services_geocoding.geocoding.html +0 -265
  83. package/docs/variables/services_geolocation.geolocation.html +0 -79
  84. package/docs/variables/services_staticMaps.staticMaps.html +0 -128
  85. package/docsmd/.nojekyll +0 -1
  86. package/docsmd/README.md +0 -873
  87. package/docsmd/assets/custom.css +0 -118
  88. package/docsmd/classes/ClientConfig.md +0 -90
  89. package/docsmd/classes/MapStyleVariant.md +0 -234
  90. package/docsmd/classes/ReferenceMapStyle.md +0 -169
  91. package/docsmd/classes/ServiceError.md +0 -52
  92. package/examples/test-browser-es.html +0 -103
  93. package/examples/test-browser-umd.html +0 -90
  94. package/examples/test-node.js +0 -52
  95. package/images/JS-logo.svg +0 -4
  96. package/images/TS-logo.svg +0 -6
  97. package/images/maptiler-client-logo.afdesign +0 -0
  98. package/images/maptiler-client-logo.svg +0 -75
  99. package/images/maptiler-logo-256.png +0 -0
  100. package/images/maptiler-logo.svg +0 -23
  101. package/images/screenshots/static-bounded-europe-1024.png +0 -0
  102. package/images/screenshots/static-bounded-europe-2048.png +0 -0
  103. package/images/screenshots/static-bounded-portugal-1024x2048.png +0 -0
  104. package/images/screenshots/static-bounded-portugal-2048x2048.png +0 -0
  105. package/images/screenshots/static-with-path.png +0 -0
  106. package/src/callFetch.ts +0 -18
  107. package/src/config.ts +0 -65
  108. package/src/defaults.ts +0 -11
  109. package/src/index.ts +0 -111
  110. package/src/language.ts +0 -87
  111. package/src/mapstyle.ts +0 -968
  112. package/src/services/ServiceError.ts +0 -10
  113. package/src/services/coordinates.ts +0 -258
  114. package/src/services/data.ts +0 -63
  115. package/src/services/geocoding.ts +0 -458
  116. package/src/services/geolocation.ts +0 -139
  117. package/src/services/simplify.ts +0 -87
  118. package/src/services/staticMaps.ts +0 -463
@@ -1,10 +0,0 @@
1
- /**
2
- * A ServiceError is an Error that includes the HTTP response details
3
- */
4
- export class ServiceError extends Error {
5
- constructor(public res: Response, customMessage = "") {
6
- super(
7
- `Call to enpoint ${res.url} failed with the status code ${res.status}. ${customMessage}`
8
- );
9
- }
10
- }
@@ -1,258 +0,0 @@
1
- import { BBox, Position } from "geojson";
2
- import { callFetch } from "../callFetch";
3
- import { config } from "../config";
4
- import { defaults } from "../defaults";
5
- import { ServiceError } from "./ServiceError";
6
-
7
- const customMessages = {
8
- 403: "Key is missing, invalid or restricted",
9
- };
10
-
11
- export type CoordinatesSearchOptions = {
12
- /**
13
- * Custom MapTiler Cloud API key to use instead of the one in global `config`
14
- */
15
- apiKey?: string;
16
-
17
- /**
18
- * Maximum number of results returned (default: 10)
19
- */
20
- limit?: number;
21
-
22
- /**
23
- * Show detailed transformations for each CRS (default: false)
24
- */
25
- transformations?: boolean;
26
-
27
- /**
28
- * Show exports in WKT and Proj4 notations (default: false)
29
- */
30
- exports?: boolean;
31
- };
32
-
33
- export type CoordinateId = {
34
- authority: string;
35
- code: BigInteger;
36
- };
37
-
38
- export type CoordinateExport = {
39
- proj4: string;
40
- wkt: string;
41
- };
42
-
43
- export type CoordinateGrid = {
44
- path: string;
45
- };
46
-
47
- export type CoordinateTransformation = {
48
- id: CoordinateId;
49
- name: string;
50
- reversible: boolean;
51
- usable: boolean;
52
- deprecated: boolean;
53
- grids: Array<CoordinateGrid>;
54
- accuracy?: number;
55
- area?: string;
56
- bbox?: BBox;
57
- target_crs?: CoordinateId;
58
- unit?: string;
59
- };
60
-
61
- export type CoordinateSearch = {
62
- id: CoordinateId;
63
-
64
- name: string;
65
-
66
- kind: string;
67
-
68
- deprecated: boolean;
69
-
70
- transformations?: Array<CoordinateTransformation | number>;
71
-
72
- accuracy?: number;
73
-
74
- unit?: string;
75
-
76
- area?: string;
77
-
78
- /**
79
- * Bounding box of the resource in [min_lon, min_lat, max_lon, max_lat] order.
80
- */
81
- bbox?: BBox;
82
-
83
- /**
84
- * Most suitable transformation for this CRS.
85
- */
86
- default_transformation?: any;
87
-
88
- exports: CoordinateExport;
89
- };
90
-
91
- export type CoordinateSearchResult = {
92
- /**
93
- * The coordinate search results
94
- */
95
- results: Array<CoordinateSearch>;
96
-
97
- /**
98
- * The number of results
99
- */
100
- total: number;
101
- };
102
-
103
- /**
104
- * Search information about coordinate systems using MapTiler API.
105
- * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/coordinates/#search-coordinate-systems
106
- * @param query Can be any kind of CRS by name or code
107
- * @param options
108
- * @returns
109
- */
110
- async function search(
111
- query: string,
112
- options: CoordinatesSearchOptions = {}
113
- ): Promise<CoordinateSearchResult> {
114
- if (typeof query !== "string" || query.trim().length === 0) {
115
- throw new Error("The query must be a non-empty string");
116
- }
117
-
118
- const endpoint = new URL(
119
- `coordinates/search/${query}.json`,
120
- defaults.maptilerApiURL
121
- );
122
- endpoint.searchParams.set("key", options.apiKey ?? config.apiKey);
123
-
124
- if ("limit" in options) {
125
- endpoint.searchParams.set("limit", options.limit.toString());
126
- }
127
-
128
- if ("transformations" in options) {
129
- endpoint.searchParams.set(
130
- "transformations",
131
- options.transformations.toString()
132
- );
133
- }
134
-
135
- if ("exports" in options) {
136
- endpoint.searchParams.set("exports", options.exports.toString());
137
- }
138
-
139
- const urlWithParams = endpoint.toString();
140
- const res = await callFetch(urlWithParams);
141
-
142
- if (!res.ok) {
143
- throw new ServiceError(
144
- res,
145
- res.status in customMessages ? customMessages[res.status] : ""
146
- );
147
- }
148
-
149
- const obj = await res.json();
150
- return obj as CoordinateSearchResult;
151
- }
152
-
153
- export type XYZ = {
154
- x?: number;
155
- y?: number;
156
- z?: number;
157
- };
158
-
159
- export type CoordinateTransformResult = {
160
- results: Array<XYZ>;
161
-
162
- /**
163
- * Transformations are selected using given ops parameter.
164
- * If no parameter is given, auto strategy is used.
165
- * If given, it may try to use a listed transformation,
166
- * then fallback to towgs84 patching, and finally boundcrs.
167
- */
168
- transformer_selection_strategy: string;
169
- };
170
-
171
- /**
172
- * Options that can be provided when transforming a coordinate from one CRS to another.
173
- */
174
- export type CoordinatesTransformOptions = {
175
- /**
176
- * Custom MapTiler Cloud API key to use instead of the one in global `config`
177
- */
178
- apiKey?: string;
179
-
180
- /**
181
- * Source coordinate reference system (default: 4326)
182
- */
183
- sourceCrs?: number;
184
-
185
- /**
186
- * Target coordinate reference system (default: 4326)
187
- */
188
- targetCrs?: number;
189
-
190
- /**
191
- * List of codes of operations
192
- */
193
- operations?: number | Array<number>;
194
- };
195
-
196
- /**
197
- * Transforms coordinates from a source reference system to a target reference system using MapTiler API.
198
- * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/coordinates/#transform-coordinates
199
- * @param positions
200
- * @param options
201
- * @returns
202
- */
203
- async function transform(
204
- positions: Position | Array<Position>,
205
- options: CoordinatesTransformOptions = {}
206
- ): Promise<CoordinateTransformResult> {
207
- const coordinatesStr = (Array.isArray(positions[0]) ? positions : [positions])
208
- .map((coord) => `${coord[0]},${coord[1]}`)
209
- .join(";");
210
-
211
- const endpoint = new URL(
212
- `coordinates/transform/${coordinatesStr}.json`,
213
- defaults.maptilerApiURL
214
- );
215
- endpoint.searchParams.set("key", options.apiKey ?? config.apiKey);
216
-
217
- if ("sourceCrs" in options) {
218
- endpoint.searchParams.set("s_srs", options.sourceCrs.toString());
219
- }
220
-
221
- if ("targetCrs" in options) {
222
- endpoint.searchParams.set("t_srs", options.targetCrs.toString());
223
- }
224
-
225
- if ("operations" in options) {
226
- endpoint.searchParams.set(
227
- "ops",
228
- (Array.isArray(options.operations)
229
- ? options.operations
230
- : [options.operations]
231
- ).join("|")
232
- );
233
- }
234
-
235
- const urlWithParams = endpoint.toString();
236
- const res = await callFetch(urlWithParams);
237
-
238
- if (!res.ok) {
239
- throw new ServiceError(
240
- res,
241
- res.status in customMessages ? customMessages[res.status] : ""
242
- );
243
- }
244
-
245
- const obj = await res.json();
246
- return obj as CoordinateTransformResult;
247
- }
248
-
249
- /**
250
- * The **coordinate** namespace contains asynchronous functions to call the [MapTiler Coordinate API](https://docs.maptiler.com/cloud/api/coordinates/).
251
- * The goal of the **Coordinate API* is query information about spatial coordinate reference system (CRS) as well as to transform coordinates from one CRS to another.
252
- */
253
- const coordinates = {
254
- search,
255
- transform,
256
- };
257
-
258
- export { coordinates };
@@ -1,63 +0,0 @@
1
- import { FeatureCollection } from "geojson";
2
- import { callFetch } from "../callFetch";
3
- import { config } from "../config";
4
- import { defaults } from "../defaults";
5
- import { ServiceError } from "./ServiceError";
6
-
7
- const customMessages = {
8
- 403: "Key is missing, invalid or restricted",
9
- };
10
-
11
- /**
12
- * Options that can be provided to get user data.
13
- */
14
- export type GetDataOptions = {
15
- /**
16
- * Custom MapTiler Cloud API key to use instead of the one in global `config`
17
- */
18
- apiKey?: string;
19
- };
20
-
21
- /**
22
- * Get user data and returns it as GeoJSON using the MapTiler API.
23
- * Learn more on the MapTiler API reference page: https://docs.maptiler.com/cloud/api/data/#geojson
24
- * @param dataId
25
- * @returns
26
- */
27
- async function get(
28
- dataId: string,
29
- options: GetDataOptions = {}
30
- ): Promise<FeatureCollection> {
31
- if (typeof dataId !== "string" || dataId.trim().length === 0) {
32
- throw new Error("The data ID must be a non-empty string");
33
- }
34
-
35
- const endpoint = new URL(
36
- `data/${encodeURIComponent(dataId)}/features.json`,
37
- defaults.maptilerApiURL
38
- );
39
- endpoint.searchParams.set("key", options.apiKey ?? config.apiKey);
40
- const urlWithParams = endpoint.toString();
41
-
42
- const res = await callFetch(urlWithParams);
43
-
44
- if (!res.ok) {
45
- throw new ServiceError(
46
- res,
47
- res.status in customMessages ? customMessages[res.status] : ""
48
- );
49
- }
50
-
51
- const obj = await res.json();
52
- return obj;
53
- }
54
-
55
- /**
56
- * The **data** namespace contains an asynchronous function to call the [MapTiler Data API](https://docs.maptiler.com/cloud/api/data/).
57
- * The **Data API** provides a way to retrieve user data in GeoJSON format.
58
- */
59
- const data = {
60
- get,
61
- };
62
-
63
- export { data };