@maptiler/sdk 1.0.5 → 1.0.6
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 +4 -0
- package/demos/maptiler-sdk.umd.js +10 -7
- package/dist/maptiler-sdk.d.ts +53 -2
- package/dist/maptiler-sdk.min.mjs +1 -1
- package/dist/maptiler-sdk.mjs +8 -8
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +10 -7
- package/dist/maptiler-sdk.umd.js.map +1 -1
- package/dist/maptiler-sdk.umd.min.js +4 -4
- package/package.json +1 -1
- package/src/Map.ts +7 -7
- package/src/{CustomGeolocateControl.ts → MaptilerGeolocateControl.ts} +7 -1
- package/src/{CustomLogoControl.ts → MaptilerLogoControl.ts} +3 -2
- package/src/{TerrainControl.ts → MaptilerTerrainControl.ts} +3 -13
- package/src/index.ts +7 -0
package/package.json
CHANGED
package/src/Map.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
10
10
|
import { ReferenceMapStyle, MapStyleVariant } from "@maptiler/client";
|
|
11
11
|
import { config } from "./config";
|
|
12
12
|
import { defaults } from "./defaults";
|
|
13
|
-
import {
|
|
13
|
+
import { MaptilerLogoControl } from "./MaptilerLogoControl";
|
|
14
14
|
import { enableRTL } from "./tools";
|
|
15
15
|
import {
|
|
16
16
|
getBrowserLanguage,
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
LanguageString,
|
|
20
20
|
} from "./language";
|
|
21
21
|
import { styleToStyle } from "./mapstyle";
|
|
22
|
-
import {
|
|
22
|
+
import { MaptilerTerrainControl } from "./MaptilerTerrainControl";
|
|
23
23
|
import { MaptilerNavigationControl } from "./MaptilerNavigationControl";
|
|
24
24
|
import { geolocation } from "@maptiler/client";
|
|
25
|
-
import {
|
|
25
|
+
import { MaptilerGeolocateControl } from "./MaptilerGeolocateControl";
|
|
26
26
|
|
|
27
27
|
// StyleSwapOptions is not exported by Maplibre, but we can redefine it (used for setStyle)
|
|
28
28
|
export type TransformStyleFunction = (
|
|
@@ -323,7 +323,7 @@ export class Map extends maplibregl.Map {
|
|
|
323
323
|
const logoURL: string = tileJsonContent.logo;
|
|
324
324
|
|
|
325
325
|
this.addControl(
|
|
326
|
-
new
|
|
326
|
+
new MaptilerLogoControl({ logoURL }),
|
|
327
327
|
options.logoPosition
|
|
328
328
|
);
|
|
329
329
|
|
|
@@ -332,7 +332,7 @@ export class Map extends maplibregl.Map {
|
|
|
332
332
|
this.addControl(new maplibregl.AttributionControl(options));
|
|
333
333
|
}
|
|
334
334
|
} else if (options.maptilerLogo) {
|
|
335
|
-
this.addControl(new
|
|
335
|
+
this.addControl(new MaptilerLogoControl(), options.logoPosition);
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
// the other controls at init time but be after
|
|
@@ -376,7 +376,7 @@ export class Map extends maplibregl.Map {
|
|
|
376
376
|
|
|
377
377
|
this.addControl(
|
|
378
378
|
// new maplibregl.GeolocateControl({
|
|
379
|
-
new
|
|
379
|
+
new MaptilerGeolocateControl({
|
|
380
380
|
positionOptions: {
|
|
381
381
|
enableHighAccuracy: true,
|
|
382
382
|
maximumAge: 0,
|
|
@@ -401,7 +401,7 @@ export class Map extends maplibregl.Map {
|
|
|
401
401
|
? "top-right"
|
|
402
402
|
: options.terrainControl
|
|
403
403
|
) as ControlPosition;
|
|
404
|
-
this.addControl(new
|
|
404
|
+
this.addControl(new MaptilerTerrainControl(), position);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
// By default, no fullscreen control
|
|
@@ -6,7 +6,13 @@ const GeolocateControl = maplibregl.GeolocateControl;
|
|
|
6
6
|
const Marker = maplibregl.Marker;
|
|
7
7
|
const LngLat = maplibregl.LngLat;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The MaptilerGeolocateControl is an extension of the original GeolocateControl
|
|
11
|
+
* with a few changes. In this version, the active mode persists as long as the
|
|
12
|
+
* location is still centered. This means it's robust to rotation, pitch and zoom.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export class MaptilerGeolocateControl extends GeolocateControl {
|
|
10
16
|
private lastUpdatedCenter = new LngLat(0, 0);
|
|
11
17
|
|
|
12
18
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import maplibregl from "maplibre-gl";
|
|
2
|
+
import type { LogoOptions as LogoOptionsML } from "maplibre-gl";
|
|
2
3
|
import { defaults } from "./defaults";
|
|
3
4
|
import { Map } from "./Map";
|
|
4
5
|
|
|
5
|
-
type LogoOptions =
|
|
6
|
+
type LogoOptions = LogoOptionsML & {
|
|
6
7
|
logoURL?: string;
|
|
7
8
|
linkURL?: string;
|
|
8
9
|
};
|
|
@@ -11,7 +12,7 @@ type LogoOptions = maplibregl.LogoOptions & {
|
|
|
11
12
|
* This LogoControl extends the MapLibre LogoControl but instead can use any image URL and
|
|
12
13
|
* any link URL. By default this is using MapTiler logo and URL.
|
|
13
14
|
*/
|
|
14
|
-
export class
|
|
15
|
+
export class MaptilerLogoControl extends maplibregl.LogoControl {
|
|
15
16
|
private logoURL = "";
|
|
16
17
|
private linkURL = "";
|
|
17
18
|
|
|
@@ -4,20 +4,10 @@ import { Map } from "./Map";
|
|
|
4
4
|
import maplibregl from "maplibre-gl";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @implements {IControl}
|
|
10
|
-
* @param {Object} [options]
|
|
11
|
-
* @param {string} [options.id] The ID of the raster-dem source to use.
|
|
12
|
-
* @param {Object} [options.options]
|
|
13
|
-
* @param {number} [options.options.exaggeration]
|
|
14
|
-
* @example
|
|
15
|
-
* var map = new maplibregl.Map({TerrainControl: false})
|
|
16
|
-
* .addControl(new maplibregl.TerrainControl({
|
|
17
|
-
* source: "terrain"
|
|
18
|
-
* }));
|
|
7
|
+
* A `MaptilerTerrainControl` control adds a button to turn terrain on and off
|
|
8
|
+
* by triggering the terrain logic that is already deployed in the Map object.
|
|
19
9
|
*/
|
|
20
|
-
export class
|
|
10
|
+
export class MaptilerTerrainControl implements maplibregl.IControl {
|
|
21
11
|
_map: Map;
|
|
22
12
|
_container: HTMLElement;
|
|
23
13
|
_terrainButton: HTMLButtonElement;
|
package/src/index.ts
CHANGED
|
@@ -97,6 +97,10 @@ export {
|
|
|
97
97
|
import { Map, GeolocationType } from "./Map";
|
|
98
98
|
import type { MapOptions } from "./Map";
|
|
99
99
|
|
|
100
|
+
import { MaptilerGeolocateControl } from "./MaptilerGeolocateControl";
|
|
101
|
+
import { MaptilerLogoControl } from "./MaptilerLogoControl";
|
|
102
|
+
import { MaptilerTerrainControl } from "./MaptilerTerrainControl";
|
|
103
|
+
|
|
100
104
|
// importing client functions to expose them as part of the SDK
|
|
101
105
|
import type {
|
|
102
106
|
BBox,
|
|
@@ -168,4 +172,7 @@ export {
|
|
|
168
172
|
Point,
|
|
169
173
|
ReferenceMapStyle,
|
|
170
174
|
MapStyleVariant,
|
|
175
|
+
MaptilerGeolocateControl,
|
|
176
|
+
MaptilerLogoControl,
|
|
177
|
+
MaptilerTerrainControl,
|
|
171
178
|
};
|