@maptiler/sdk 1.0.2 → 1.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptiler/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
5
5
  "module": "dist/maptiler-sdk.mjs",
6
6
  "types": "dist/maptiler-sdk.d.ts",
package/readme.md CHANGED
@@ -593,7 +593,7 @@ const imageLink = maptilerClient.staticMaps.automatic({
593
593
  path: trackPoints,
594
594
 
595
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'],
596
+ markers: [trackPoints[0][0], trackPoints[0][1], '#0a0'],
597
597
 
598
598
  // Showing the track in red
599
599
  pathStrokeColor: 'red',
@@ -27,8 +27,6 @@ export class CustomGeolocateControl extends GeolocateControl {
27
27
  ...this.options.fitBoundsOptions,
28
28
  };
29
29
 
30
- console.log("moving camera");
31
-
32
30
  this._map.fitBounds(center.toBounds(radius), options, {
33
31
  geolocateSource: true, // tag this camera change so it won't cause the control to change to background state
34
32
  });
@@ -36,7 +34,6 @@ export class CustomGeolocateControl extends GeolocateControl {
36
34
  let hasFittingBeenDisrupted = false;
37
35
 
38
36
  const flagFittingDisruption = () => {
39
- console.log("DISRUPTED FITTING!");
40
37
  hasFittingBeenDisrupted = true;
41
38
  };
42
39
 
@@ -48,8 +45,6 @@ export class CustomGeolocateControl extends GeolocateControl {
48
45
  this._map.once("wheel", flagFittingDisruption);
49
46
 
50
47
  this._map.once("moveend", () => {
51
- console.log("done moving, with disruption:", hasFittingBeenDisrupted);
52
-
53
48
  // Removing the events if not used
54
49
  this._map.off("click", flagFittingDisruption);
55
50
  this._map.off("dblclick", flagFittingDisruption);
package/src/Map.ts CHANGED
@@ -130,8 +130,6 @@ export class Map extends maplibregl.Map {
130
130
 
131
131
  constructor(options: MapOptions) {
132
132
  const style = styleToStyle(options.style);
133
- console.log(style);
134
-
135
133
  const hashPreConstructor = location.hash;
136
134
 
137
135
  if (!config.apiKey) {
@@ -147,7 +145,19 @@ export class Map extends maplibregl.Map {
147
145
  maplibreLogo: false,
148
146
 
149
147
  transformRequest: (url: string) => {
150
- const reqUrl = new URL(url);
148
+ let reqUrl = null;
149
+
150
+ try {
151
+ // The URL is expected to be absolute.
152
+ // Yet, if it's local we just return it without assuming a 'base' url (in the URL constructor)
153
+ // and we let the URL be locally resolved with a potential base path.
154
+ reqUrl = new URL(url);
155
+ } catch (e) {
156
+ return {
157
+ url,
158
+ headers: {},
159
+ };
160
+ }
151
161
 
152
162
  if (reqUrl.host === defaults.maptilerApiHost) {
153
163
  if (!reqUrl.searchParams.has("key")) {
package/src/mapstyle.ts CHANGED
@@ -23,7 +23,13 @@ export function styleToStyle(
23
23
 
24
24
  // If the provided style is a shorthand (eg. "streets-v2") or a full style URL
25
25
  if (typeof style === "string" || style instanceof String) {
26
- return expandMapStyle(style);
26
+ if (!style.startsWith("http") && style.toLowerCase().includes(".json")) {
27
+ // If a style does not start by http but still contains the extension ".json"
28
+ // we assume it's a relative path to a style json file
29
+ return style as string;
30
+ } else {
31
+ return expandMapStyle(style);
32
+ }
27
33
  }
28
34
 
29
35
  if (style instanceof MapStyleVariant) {