@maptiler/sdk 1.0.2 → 1.0.4
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/CHANGELOG.md +16 -0
- package/demos/maptiler-sdk.umd.js +25 -8
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +25 -8
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +25 -8
- package/dist/maptiler-sdk.umd.js.map +1 -1
- package/dist/maptiler-sdk.umd.min.js +34 -34
- package/package.json +1 -1
- package/readme.md +1 -1
- package/src/CustomGeolocateControl.ts +6 -4
- package/src/Map.ts +13 -3
- package/src/TerrainControl.ts +0 -6
- package/src/mapstyle.ts +7 -1
package/package.json
CHANGED
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
|
-
|
|
596
|
+
markers: [trackPoints[0][0], trackPoints[0][1], '#0a0'],
|
|
597
597
|
|
|
598
598
|
// Showing the track in red
|
|
599
599
|
pathStrokeColor: 'red',
|
|
@@ -25,9 +25,14 @@ export class CustomGeolocateControl extends GeolocateControl {
|
|
|
25
25
|
const options = {
|
|
26
26
|
bearing,
|
|
27
27
|
...this.options.fitBoundsOptions,
|
|
28
|
+
linear: true,
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
const currentMapZoom = this._map.getZoom();
|
|
32
|
+
|
|
33
|
+
if (currentMapZoom > this.options.fitBoundsOptions.maxZoom) {
|
|
34
|
+
options.zoom = currentMapZoom;
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
this._map.fitBounds(center.toBounds(radius), options, {
|
|
33
38
|
geolocateSource: true, // tag this camera change so it won't cause the control to change to background state
|
|
@@ -36,7 +41,6 @@ export class CustomGeolocateControl extends GeolocateControl {
|
|
|
36
41
|
let hasFittingBeenDisrupted = false;
|
|
37
42
|
|
|
38
43
|
const flagFittingDisruption = () => {
|
|
39
|
-
console.log("DISRUPTED FITTING!");
|
|
40
44
|
hasFittingBeenDisrupted = true;
|
|
41
45
|
};
|
|
42
46
|
|
|
@@ -48,8 +52,6 @@ export class CustomGeolocateControl extends GeolocateControl {
|
|
|
48
52
|
this._map.once("wheel", flagFittingDisruption);
|
|
49
53
|
|
|
50
54
|
this._map.once("moveend", () => {
|
|
51
|
-
console.log("done moving, with disruption:", hasFittingBeenDisrupted);
|
|
52
|
-
|
|
53
55
|
// Removing the events if not used
|
|
54
56
|
this._map.off("click", flagFittingDisruption);
|
|
55
57
|
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
|
-
|
|
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/TerrainControl.ts
CHANGED
|
@@ -53,12 +53,6 @@ export class TerrainControl implements maplibregl.IControl {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
_toggleTerrain() {
|
|
56
|
-
// if (this._map.getTerrain()) {
|
|
57
|
-
// this._map.setTerrain(null);
|
|
58
|
-
// } else {
|
|
59
|
-
// this._map.setTerrain(this.options);
|
|
60
|
-
// }
|
|
61
|
-
|
|
62
56
|
if (this._map.hasTerrain()) {
|
|
63
57
|
this._map.disableTerrain();
|
|
64
58
|
} else {
|
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
|
-
|
|
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) {
|