@mapcreator/sdk 2.0.2 → 3.1.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.
- package/README.md +26 -6
- package/dist/Image.d.ts +13 -0
- package/dist/MCMap.d.ts +68 -17
- package/dist/Video.d.ts +3 -2
- package/dist/adornments/categoricalLegend.d.ts +2 -1
- package/dist/adornments/connectedLegend.d.ts +3 -2
- package/dist/adornments/copyright.d.ts +6 -2
- package/dist/adornments/heading.d.ts +2 -1
- package/dist/adornments/manualLegend.d.ts +2 -1
- package/dist/adornments/scalebar.d.ts +2 -1
- package/dist/constants/index.d.ts +3 -2
- package/dist/events.d.ts +12 -0
- package/dist/index.bundler.d.ts +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/mapcreator-sdk-worker.mjs +10 -0
- package/dist/mapcreator-sdk.bundler.mjs +6228 -0
- package/dist/mapcreator-sdk.css +1 -1
- package/dist/mapcreator-sdk.mjs +545 -0
- package/dist/maplibre-gl-shared.mjs +6 -0
- package/dist/maplibre-gl-worker.mjs +6 -0
- package/dist/maplibre-gl.mjs +819 -0
- package/dist/models/line.d.ts +2 -1
- package/dist/renderAdornments.d.ts +2 -2
- package/dist/types/index.d.ts +0 -6
- package/dist/utils/fonts.d.ts +47 -3
- package/dist/utils/geoTiff.d.ts +13 -0
- package/dist/utils/helpers.d.ts +4 -2
- package/dist/utils/labelFreeAreas.d.ts +3 -0
- package/dist/utils/pdfFonts.d.ts +22 -0
- package/dist/utils/svg2pdf.d.ts +21 -0
- package/dist/utils/svgHelpers.d.ts +25 -9
- package/package.json +14 -13
- package/dist/mapcreator-sdk.js +0 -41109
- package/dist/mapcreator-sdk.umd.cjs +0 -1227
- package/dist/report.html +0 -4950
package/README.md
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
[Mapcreator](https://mapcreator.io/) JavaScript SDK. Renders Mapcreator projects on a [MapLibre](https://maplibre.org/) interactive map.
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Usage with a bundler
|
|
4
4
|
|
|
5
5
|
```
|
|
6
6
|
npm i --save @mapcreator/sdk
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
9
|
```javascript
|
|
12
|
-
// Import scripts
|
|
13
|
-
import { initMap } from '@mapcreator/sdk';
|
|
14
|
-
|
|
15
10
|
// Import styles
|
|
16
11
|
import '@mapcreator/sdk/dist/mapcreator-sdk.css';
|
|
17
12
|
|
|
13
|
+
// Import scripts
|
|
14
|
+
import { initMap } from '@mapcreator/sdk';
|
|
15
|
+
|
|
18
16
|
// Initialize the map
|
|
19
17
|
const { map } = await initMap({
|
|
20
18
|
container: '<map container element or its id>',
|
|
@@ -27,3 +25,25 @@ const { map } = await initMap({
|
|
|
27
25
|
// map.setZoom(10);
|
|
28
26
|
// map.getZoom();
|
|
29
27
|
```
|
|
28
|
+
|
|
29
|
+
## Usage in the browser
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<link rel="stylesheet" href="https://unpkg.com/@mapcreator/sdk@^3.0.0/dist/mapcreator-sdk.css" />
|
|
33
|
+
<div id="map" style="height: 400px"></div>
|
|
34
|
+
|
|
35
|
+
<script type="module">
|
|
36
|
+
import { initMap } from 'https://unpkg.com/@mapcreator/sdk@^3.0.0/dist/mapcreator-sdk.mjs';
|
|
37
|
+
|
|
38
|
+
const { map } = await initMap({
|
|
39
|
+
container: 'map',
|
|
40
|
+
job: '<interactive map id>',
|
|
41
|
+
accessToken: '<mapcreator access token>',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// map is now an instance of MapLibre GL JS:
|
|
45
|
+
//
|
|
46
|
+
// map.setZoom(10);
|
|
47
|
+
// map.getZoom();
|
|
48
|
+
</script>
|
|
49
|
+
```
|
package/dist/Image.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SvgCache } from './utils/svgHelpers';
|
|
2
|
+
import { JobObjectFormat } from './types/jobObject';
|
|
3
|
+
import { MCMap } from './MCMap';
|
|
4
|
+
export declare class Image {
|
|
5
|
+
private mcMap;
|
|
6
|
+
private format;
|
|
7
|
+
private svgCache;
|
|
8
|
+
private backgroundColor;
|
|
9
|
+
constructor(mcMap: MCMap, format: JobObjectFormat, svgCache: SvgCache, backgroundColor: string);
|
|
10
|
+
frame(asBlob: true): Promise<Blob>;
|
|
11
|
+
frame(asBlob: false): Promise<ImageData>;
|
|
12
|
+
frame(asBlob: boolean): Promise<Blob | ImageData>;
|
|
13
|
+
}
|
package/dist/MCMap.d.ts
CHANGED
|
@@ -1,28 +1,79 @@
|
|
|
1
1
|
import { Evented, Map as MapLibre, StyleSpecification } from '@mapcreator/maplibre-gl';
|
|
2
|
+
import { JobObject, JobObjectFormat } from './types/jobObject';
|
|
2
3
|
import { ExportType, LayerInfo, Svgs } from './types';
|
|
3
|
-
import { JobObject } from './types/jobObject';
|
|
4
4
|
import { SvgCache } from './utils/svgHelpers';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
playend: VideoEvent;
|
|
8
|
-
play: VideoEvent;
|
|
9
|
-
};
|
|
10
|
-
type VideoEvent = {
|
|
11
|
-
time: number;
|
|
12
|
-
};
|
|
13
|
-
export declare class MCMap extends Evented {
|
|
5
|
+
import { SdkEventType } from './events';
|
|
6
|
+
export declare class MCMap extends Evented<SdkEventType> {
|
|
14
7
|
map: MapLibre;
|
|
8
|
+
private format;
|
|
9
|
+
private mapstyle;
|
|
10
|
+
private svgCache;
|
|
11
|
+
private backgroundColor;
|
|
12
|
+
private vapiUrl;
|
|
13
|
+
private accessToken;
|
|
14
|
+
private image;
|
|
15
15
|
private video;
|
|
16
|
-
constructor(map: MapLibre, exportType: ExportType, jobObject: JobObject, svgs: Svgs, svgCache: SvgCache, mapstyle: StyleSpecification, overlays: Map<number, StyleSpecification>, layerInfo: LayerInfo, backgroundColor: string);
|
|
17
|
-
on<T extends keyof SdkEventType>(type: T, listener: (e: SdkEventType[T]) => void): import('@mapcreator/maplibre-gl').Subscription;
|
|
18
|
-
once<T extends keyof SdkEventType>(type: T, listener: (e: SdkEventType[T]) => void): Promise<any> | this;
|
|
19
|
-
off<T extends keyof SdkEventType>(type: T, listener: (e: SdkEventType[T]) => void): this;
|
|
20
|
-
fire<T extends keyof SdkEventType>(type: T, payload: SdkEventType[T]): this;
|
|
16
|
+
constructor(map: MapLibre, format: JobObjectFormat, exportType: ExportType, jobObject: JobObject, svgs: Svgs, svgCache: SvgCache, mapstyle: StyleSpecification, overlays: Map<number, StyleSpecification>, layerInfo: LayerInfo, backgroundColor: string, vapiUrl: string, accessToken: string);
|
|
21
17
|
play(): void;
|
|
22
18
|
pause(): void;
|
|
23
19
|
seekTo(time: number): void;
|
|
24
|
-
frames(): AsyncGenerator<
|
|
20
|
+
frames(asBlob: true): AsyncGenerator<Blob, void, void>;
|
|
21
|
+
frames(asBlob?: false): AsyncGenerator<ImageData, void, void>;
|
|
22
|
+
frames(asBlob?: boolean): AsyncGenerator<Blob | ImageData, void, void>;
|
|
25
23
|
preload(): Promise<void>;
|
|
24
|
+
geoTiffMetadata(size: {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}): {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
GTRasterTypeGeoKey: number;
|
|
31
|
+
PhotometricInterpretation: number;
|
|
32
|
+
ProjectedCSTypeGeoKey: number;
|
|
33
|
+
ModelTiepoint: number[];
|
|
34
|
+
ModelPixelScale: never[];
|
|
35
|
+
};
|
|
36
|
+
svgExportOptions(api: {
|
|
37
|
+
href?: string;
|
|
38
|
+
token: string;
|
|
39
|
+
}, geoRef?: boolean, signal?: AbortSignal | undefined): {
|
|
40
|
+
map: MapLibre;
|
|
41
|
+
api: {
|
|
42
|
+
href?: string;
|
|
43
|
+
token: string;
|
|
44
|
+
};
|
|
45
|
+
signal: AbortSignal | undefined;
|
|
46
|
+
options: {
|
|
47
|
+
svgElements: {
|
|
48
|
+
name: string | undefined;
|
|
49
|
+
svg: string;
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
w: number;
|
|
53
|
+
h: number;
|
|
54
|
+
}[];
|
|
55
|
+
fillPatterns: {
|
|
56
|
+
name: string;
|
|
57
|
+
string: string;
|
|
58
|
+
}[];
|
|
59
|
+
backgroundColor: string;
|
|
60
|
+
detailLevel: number;
|
|
61
|
+
forPDF: boolean;
|
|
62
|
+
geoRef: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
pdfExportOptions(api: {
|
|
66
|
+
href?: string;
|
|
67
|
+
token: string;
|
|
68
|
+
}): {
|
|
69
|
+
colorCallback: (inValue: [[number, number, number], number] | undefined) => [[number, number, number, number], number] | undefined;
|
|
70
|
+
fontCallback: (family: string, requestedWeight: number, requestedStyle: string, doc: {
|
|
71
|
+
registerFont(name: string, data: ArrayBuffer): unknown;
|
|
72
|
+
}, fontOptions?: {
|
|
73
|
+
fauxBold: boolean;
|
|
74
|
+
fauxItalic: boolean;
|
|
75
|
+
}) => Promise<string>;
|
|
76
|
+
assumePt: boolean;
|
|
77
|
+
};
|
|
26
78
|
remove(): void;
|
|
27
79
|
}
|
|
28
|
-
export {};
|
package/dist/Video.d.ts
CHANGED
|
@@ -28,7 +28,9 @@ export declare class Video {
|
|
|
28
28
|
pause(): void;
|
|
29
29
|
seekTo(time: number): void;
|
|
30
30
|
remove(): void;
|
|
31
|
-
frames(): AsyncGenerator<
|
|
31
|
+
frames(asBlob: true): AsyncGenerator<Blob, void, void>;
|
|
32
|
+
frames(asBlob: false): AsyncGenerator<ImageData, void, void>;
|
|
33
|
+
frames(asBlob: boolean): AsyncGenerator<Blob | ImageData, void, void>;
|
|
32
34
|
preload(): Promise<void>;
|
|
33
35
|
/**
|
|
34
36
|
* Waits for the next 'render' or a meaningful 'dataabort' event, whichever
|
|
@@ -38,7 +40,6 @@ export declare class Video {
|
|
|
38
40
|
*/
|
|
39
41
|
private waitForRenderOrAbort;
|
|
40
42
|
private captureFrame;
|
|
41
|
-
private drawAdornments;
|
|
42
43
|
private playFrame;
|
|
43
44
|
private setFrame;
|
|
44
45
|
private setCamera;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { Fonts } from '../utils/fonts';
|
|
1
2
|
import { JobObjectManualLegend } from '../types/jobObject';
|
|
2
|
-
export declare function getCategoricalLegendSvg(legend: JobObjectManualLegend, defaultFont: string, mapScale: number): string;
|
|
3
|
+
export declare function getCategoricalLegendSvg(legend: JobObjectManualLegend, defaultFont: string, mapScale: number, fonts: Fonts): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Fonts } from '../utils/fonts';
|
|
1
2
|
import { Map as MapLibre } from '@mapcreator/maplibre-gl';
|
|
2
|
-
import { JobObject, JobObjectConnectedLegend } from '../types/jobObject';
|
|
3
3
|
import { ExportType } from '../types';
|
|
4
|
-
|
|
4
|
+
import { JobObject, JobObjectConnectedLegend } from '../types/jobObject';
|
|
5
|
+
export declare function useConnectedLegend(legend: JobObjectConnectedLegend, jobObject: JobObject, map: MapLibre, fonts: Fonts, exportType: ExportType): {
|
|
5
6
|
element: HTMLElement;
|
|
6
7
|
ready: Promise<void>;
|
|
7
8
|
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { Map } from '@mapcreator/maplibre-gl';
|
|
2
1
|
import { JobObjectCopyright } from '../types/jobObject';
|
|
3
|
-
|
|
2
|
+
import { Fonts } from '../utils/fonts';
|
|
3
|
+
import { Map } from '@mapcreator/maplibre-gl';
|
|
4
|
+
export declare function useCopyright(copyright: JobObjectCopyright, map: Map, fonts: Fonts): {
|
|
5
|
+
element: HTMLElement;
|
|
6
|
+
ready: Promise<void>;
|
|
7
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Fonts } from '../utils/fonts';
|
|
1
2
|
import { JobObjectHeading } from '../types/jobObject';
|
|
2
3
|
import { Map } from '@mapcreator/maplibre-gl';
|
|
3
4
|
import { ExportType } from '../types';
|
|
4
|
-
export declare function useHeading(heading: JobObjectHeading, map: Map,
|
|
5
|
+
export declare function useHeading(heading: JobObjectHeading, map: Map, fonts: Fonts, exportType: ExportType): {
|
|
5
6
|
element: HTMLElement;
|
|
6
7
|
ready: Promise<void>;
|
|
7
8
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { JobObjectManualLegend } from '../types/jobObject';
|
|
2
2
|
import { Map } from '@mapcreator/maplibre-gl';
|
|
3
|
+
import { Fonts } from '../utils/fonts';
|
|
3
4
|
import { ExportType } from '../types';
|
|
4
|
-
export declare function useManualLegend(legend: JobObjectManualLegend, map: Map,
|
|
5
|
+
export declare function useManualLegend(legend: JobObjectManualLegend, map: Map, fonts: Fonts, exportType: ExportType): {
|
|
5
6
|
element: HTMLElement;
|
|
6
7
|
ready: Promise<void>;
|
|
7
8
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Fonts } from '../utils/fonts';
|
|
1
2
|
import { JobObjectScalebar } from '../types/jobObject';
|
|
2
3
|
import { Map } from '@mapcreator/maplibre-gl';
|
|
3
4
|
import { ExportType } from '../types';
|
|
4
|
-
export declare function useScalebar(scalebar: JobObjectScalebar, map: Map,
|
|
5
|
+
export declare function useScalebar(scalebar: JobObjectScalebar, map: Map, fonts: Fonts, exportType: ExportType): {
|
|
5
6
|
element: HTMLElement;
|
|
6
7
|
ready: Promise<void>;
|
|
7
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PositionOffsets, AdornmentPosition, JobObjectSlotName } from '../types/jobObject';
|
|
2
|
-
import { SkySpecification, StyleLayer } from '@mapcreator/maplibre-gl';
|
|
2
|
+
import { AllPaintProperties, SkySpecification, StyleLayer } from '@mapcreator/maplibre-gl';
|
|
3
3
|
export declare const defaultSky: SkySpecification;
|
|
4
4
|
type PositionConfig = {
|
|
5
5
|
x: 'left' | 'right' | 'center';
|
|
@@ -9,9 +9,10 @@ export declare const defaultPositionOffsets: PositionOffsets;
|
|
|
9
9
|
export declare const positionConfig: {
|
|
10
10
|
[position in AdornmentPosition]: PositionConfig;
|
|
11
11
|
};
|
|
12
|
+
export declare const adornmentSpacing = 5;
|
|
12
13
|
export declare const defaultFov = 36.87;
|
|
13
14
|
type OpacityConfig = {
|
|
14
|
-
props:
|
|
15
|
+
props: Array<keyof AllPaintProperties>;
|
|
15
16
|
defaultValue: number;
|
|
16
17
|
};
|
|
17
18
|
export declare const opacityConfigByType: Record<StyleLayer['type'], OpacityConfig>;
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Event } from '@mapcreator/maplibre-gl';
|
|
2
|
+
type VideoEventType = 'playstart' | 'playend' | 'play';
|
|
3
|
+
export declare class VideoEvent<T extends VideoEventType = VideoEventType> extends Event<T> {
|
|
4
|
+
readonly time: number;
|
|
5
|
+
constructor(type: T, time: number);
|
|
6
|
+
}
|
|
7
|
+
export type SdkEventType = {
|
|
8
|
+
playstart: VideoEvent<'playstart'>;
|
|
9
|
+
playend: VideoEvent<'playend'>;
|
|
10
|
+
play: VideoEvent<'play'>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index';
|
package/dist/index.d.ts
CHANGED