@deck.gl/carto 9.0.14 → 9.0.15
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/dist/api/basemap.d.ts +17 -0
- package/dist/api/basemap.d.ts.map +1 -0
- package/dist/api/basemap.js +76 -0
- package/dist/api/fetch-map.d.ts +10 -12
- package/dist/api/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +7 -3
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/parse-map.d.ts +21 -1
- package/dist/api/parse-map.d.ts.map +1 -1
- package/dist/api/parse-map.js +1 -0
- package/dist/api/query.d.ts.map +1 -1
- package/dist/api/query.js +4 -3
- package/dist/api/request-with-parameters.js +1 -1
- package/dist/api/types.d.ts +82 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/basemap.d.ts +17 -0
- package/dist/basemap.d.ts.map +1 -1
- package/dist/basemap.js +97 -7
- package/dist/cartoRasterTile-worker.js +1 -1
- package/dist/cartoSpatialTile-worker.js +1 -1
- package/dist/cartoVectorTile-worker.js +1 -1
- package/dist/dist.dev.js +1734 -2360
- package/dist/index.cjs +260 -82
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/layers/heatmap.d.ts +3 -2
- package/dist/layers/heatmap.d.ts.map +1 -1
- package/dist/layers/heatmap.js +18 -6
- package/dist/layers/quadbin-heatmap-tile-layer.d.ts +5 -2
- package/dist/layers/quadbin-heatmap-tile-layer.d.ts.map +1 -1
- package/dist/layers/quadbin-heatmap-tile-layer.js +3 -2
- package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -0
- package/dist.min.js +21 -15
- package/package.json +6 -6
- package/src/api/basemap.ts +100 -0
- package/src/api/fetch-map.ts +20 -6
- package/src/api/index.ts +11 -2
- package/src/api/parse-map.ts +24 -3
- package/src/api/query.ts +4 -2
- package/src/api/request-with-parameters.ts +1 -1
- package/src/api/types.ts +103 -1
- package/src/basemap.ts +134 -7
- package/src/index.ts +14 -2
- package/src/layers/heatmap.ts +23 -8
- package/src/layers/quadbin-heatmap-tile-layer.ts +8 -5
- package/src/utils.ts +5 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { APIErrorContext, Basemap, KeplerMapConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get basemap properties for Carto map.
|
|
4
|
+
*
|
|
5
|
+
* For maplibre-based basemaps it returns style or style URL that can be used with `maplibregl.Map` compatible component.
|
|
6
|
+
* * style url is returned for non-filtered standard Carto basemaps or if user used style URL directly in configuration
|
|
7
|
+
* * filtered style object returned for Carto basemaps with layer groups filtered
|
|
8
|
+
*
|
|
9
|
+
* For Google-maps base maps, it returns options that can be used with `google.maps.Map` constructor.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchBasemapProps({ config, errorContext, applyLayerFilters }: {
|
|
12
|
+
config: KeplerMapConfig;
|
|
13
|
+
/** By default `fetchBasemapProps` applies layers filters to style. Set this to `false` to disable it. */
|
|
14
|
+
applyLayerFilters?: boolean;
|
|
15
|
+
errorContext?: APIErrorContext;
|
|
16
|
+
}): Promise<Basemap | null>;
|
|
17
|
+
//# sourceMappingURL=basemap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basemap.d.ts","sourceRoot":"","sources":["../../src/api/basemap.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,eAAe,EAAE,OAAO,EAAE,eAAe,EAAuB,mBAAgB;AAaxF;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,MAAM,EACN,YAAY,EAEZ,iBAAwB,EACzB,EAAE;IACD,MAAM,EAAE,eAAe,CAAC;IAExB,yGAAyG;IACzG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAyD1B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { GOOGLE_BASEMAPS, CARTO_MAP_STYLES, applyLayerGroupFilters, fetchStyle, getStyleUrl, someLayerGroupsDisabled } from "../basemap.js";
|
|
2
|
+
const CUSTOM_STYLE_ID_PREFIX = 'custom:';
|
|
3
|
+
const DEFAULT_CARTO_STYLE = 'positron';
|
|
4
|
+
function mapLibreViewpros(config) {
|
|
5
|
+
const { longitude, latitude, ...rest } = config.mapState;
|
|
6
|
+
return {
|
|
7
|
+
center: [longitude, latitude],
|
|
8
|
+
...rest
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get basemap properties for Carto map.
|
|
13
|
+
*
|
|
14
|
+
* For maplibre-based basemaps it returns style or style URL that can be used with `maplibregl.Map` compatible component.
|
|
15
|
+
* * style url is returned for non-filtered standard Carto basemaps or if user used style URL directly in configuration
|
|
16
|
+
* * filtered style object returned for Carto basemaps with layer groups filtered
|
|
17
|
+
*
|
|
18
|
+
* For Google-maps base maps, it returns options that can be used with `google.maps.Map` constructor.
|
|
19
|
+
*/
|
|
20
|
+
export async function fetchBasemapProps({ config, errorContext, applyLayerFilters = true }) {
|
|
21
|
+
const { mapStyle } = config;
|
|
22
|
+
const styleType = mapStyle.styleType || DEFAULT_CARTO_STYLE;
|
|
23
|
+
if (styleType.startsWith(CUSTOM_STYLE_ID_PREFIX)) {
|
|
24
|
+
const currentCustomStyle = config.customBaseMaps?.customStyle;
|
|
25
|
+
if (currentCustomStyle) {
|
|
26
|
+
return {
|
|
27
|
+
type: 'maplibre',
|
|
28
|
+
props: {
|
|
29
|
+
style: currentCustomStyle.style || currentCustomStyle.url,
|
|
30
|
+
...mapLibreViewpros(config)
|
|
31
|
+
},
|
|
32
|
+
attribution: currentCustomStyle.customAttribution
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (CARTO_MAP_STYLES.includes(styleType)) {
|
|
37
|
+
const { visibleLayerGroups } = mapStyle;
|
|
38
|
+
const styleUrl = getStyleUrl(styleType);
|
|
39
|
+
let style = styleUrl;
|
|
40
|
+
let rawStyle = styleUrl;
|
|
41
|
+
if (applyLayerFilters && visibleLayerGroups && someLayerGroupsDisabled(visibleLayerGroups)) {
|
|
42
|
+
rawStyle = await fetchStyle({ styleUrl, errorContext });
|
|
43
|
+
style = applyLayerGroupFilters(rawStyle, visibleLayerGroups);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
type: 'maplibre',
|
|
47
|
+
props: {
|
|
48
|
+
style,
|
|
49
|
+
...mapLibreViewpros(config)
|
|
50
|
+
},
|
|
51
|
+
visibleLayerGroups,
|
|
52
|
+
rawStyle
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const googleBasemapDef = GOOGLE_BASEMAPS[styleType];
|
|
56
|
+
if (googleBasemapDef) {
|
|
57
|
+
const { mapState } = config;
|
|
58
|
+
return {
|
|
59
|
+
type: 'google-maps',
|
|
60
|
+
props: {
|
|
61
|
+
...googleBasemapDef,
|
|
62
|
+
center: { lat: mapState.latitude, lng: mapState.longitude },
|
|
63
|
+
zoom: mapState.zoom + 1,
|
|
64
|
+
tilt: mapState.pitch,
|
|
65
|
+
heading: mapState.bearing
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
type: 'maplibre',
|
|
71
|
+
props: {
|
|
72
|
+
style: getStyleUrl(DEFAULT_CARTO_STYLE),
|
|
73
|
+
...mapLibreViewpros(config)
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
package/dist/api/fetch-map.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ParseMapResult } from "./parse-map.js";
|
|
2
|
+
import type { Basemap } from "./types.js";
|
|
1
3
|
export type FetchMapOptions = {
|
|
2
4
|
apiBaseUrl?: string;
|
|
3
5
|
cartoMapId: string;
|
|
@@ -6,16 +8,12 @@ export type FetchMapOptions = {
|
|
|
6
8
|
autoRefresh?: number;
|
|
7
9
|
onNewData?: (map: any) => void;
|
|
8
10
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
mapStyle: any;
|
|
18
|
-
token: any;
|
|
19
|
-
layers: any;
|
|
20
|
-
}>;
|
|
11
|
+
export type FetchMapResult = ParseMapResult & {
|
|
12
|
+
/**
|
|
13
|
+
* Basemap properties.
|
|
14
|
+
*/
|
|
15
|
+
basemap: Basemap | null;
|
|
16
|
+
stopAutoRefresh?: () => void;
|
|
17
|
+
};
|
|
18
|
+
export declare function fetchMap({ apiBaseUrl, cartoMapId, clientId, headers, autoRefresh, onNewData }: FetchMapOptions): Promise<FetchMapResult>;
|
|
21
19
|
//# sourceMappingURL=fetch-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-map.d.ts","sourceRoot":"","sources":["../../src/api/fetch-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-map.d.ts","sourceRoot":"","sources":["../../src/api/fetch-map.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,cAAc,EAAW,uBAAoB;AAGrD,OAAO,KAAK,EAAkB,OAAO,EAAmC,mBAAgB;AAyLxF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG;IAC5C;;OAEG;IACH,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAGF,wBAAsB,QAAQ,CAAC,EAC7B,UAAiC,EACjC,UAAU,EACV,QAAyB,EACzB,OAAY,EACZ,WAAW,EACX,SAAS,EACV,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA+E3C"}
|
package/dist/api/fetch-map.js
CHANGED
|
@@ -9,6 +9,7 @@ import { h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, v
|
|
|
9
9
|
import { parseMap } from "./parse-map.js";
|
|
10
10
|
import { requestWithParameters } from "./request-with-parameters.js";
|
|
11
11
|
import { assert } from "../utils.js";
|
|
12
|
+
import { fetchBasemapProps } from "./basemap.js";
|
|
12
13
|
/* global clearInterval, setInterval, URL */
|
|
13
14
|
/* eslint-disable complexity, max-statements */
|
|
14
15
|
async function _fetchMapDataset(dataset, accessToken, apiBaseUrl, clientId, headers) {
|
|
@@ -177,11 +178,14 @@ export async function fetchMap({ apiBaseUrl = DEFAULT_API_BASE_URL, cartoMapId,
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
});
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
const [basemap] = await Promise.all([
|
|
182
|
+
fetchBasemapProps({ config: map.keplerMapConfig.config, errorContext }),
|
|
183
|
+
// Mutates map.datasets so that dataset.data contains data
|
|
184
|
+
fillInMapDatasets(map, clientId, apiBaseUrl, headers)
|
|
185
|
+
]);
|
|
182
186
|
// Mutates attributes in visualChannels to contain tile stats
|
|
183
187
|
await fillInTileStats(map, apiBaseUrl);
|
|
184
|
-
const out = { ...parseMap(map), ...{ stopAutoRefresh } };
|
|
188
|
+
const out = { ...parseMap(map), basemap, ...{ stopAutoRefresh } };
|
|
185
189
|
const textLayers = out.layers.filter(layer => {
|
|
186
190
|
const pointType = layer.props.pointType || '';
|
|
187
191
|
return pointType.includes('text');
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CartoAPIError } from "./carto-api-error.js";
|
|
2
2
|
export { fetchMap } from "./fetch-map.js";
|
|
3
|
-
export type { FetchMapOptions } from "./fetch-map.js";
|
|
4
|
-
export type { APIErrorContext, Format, MapType, RequestType, QueryParameters } from "./types.js";
|
|
3
|
+
export type { FetchMapOptions, FetchMapResult } from "./fetch-map.js";
|
|
4
|
+
export type { APIErrorContext, Format, MapType, RequestType, QueryParameters, Basemap, MapLibreBasemap, GoogleBasemap } from "./types.js";
|
|
5
5
|
export { query } from "./query.js";
|
|
6
6
|
export type { QueryOptions } from "./query.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,6BAA0B;AAChD,OAAO,EAAC,QAAQ,EAAC,uBAAoB;AACrC,YAAY,EAAC,eAAe,EAAC,uBAAoB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,6BAA0B;AAChD,OAAO,EAAC,QAAQ,EAAC,uBAAoB;AACrC,YAAY,EAAC,eAAe,EAAE,cAAc,EAAC,uBAAoB;AACjE,YAAY,EACV,eAAe,EACf,MAAM,EACN,OAAO,EACP,WAAW,EACX,eAAe,EACf,OAAO,EACP,eAAe,EACf,aAAa,EACd,mBAAgB;AACjB,OAAO,EAAC,KAAK,EAAC,mBAAgB;AAC9B,YAAY,EAAC,YAAY,EAAC,mBAAgB"}
|
package/dist/api/parse-map.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import { Layer } from '@deck.gl/core';
|
|
2
|
+
export type ParseMapResult = {
|
|
3
|
+
/** Map id. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Title of map. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Description of map. */
|
|
8
|
+
description?: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
initialViewState: any;
|
|
12
|
+
/** @deprecated Use `basemap`. */
|
|
13
|
+
mapStyle: any;
|
|
14
|
+
token: string;
|
|
15
|
+
layers: Layer[];
|
|
16
|
+
};
|
|
1
17
|
export declare function parseMap(json: any): {
|
|
2
18
|
id: any;
|
|
3
19
|
title: any;
|
|
@@ -5,7 +21,11 @@ export declare function parseMap(json: any): {
|
|
|
5
21
|
createdAt: any;
|
|
6
22
|
updatedAt: any;
|
|
7
23
|
initialViewState: any;
|
|
8
|
-
|
|
24
|
+
/** @deprecated Use `basemap`. */
|
|
25
|
+
mapStyle: {
|
|
26
|
+
styleType: string;
|
|
27
|
+
visibleLayerGroups: Record<string, boolean>;
|
|
28
|
+
};
|
|
9
29
|
token: any;
|
|
10
30
|
layers: any;
|
|
11
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-map.d.ts","sourceRoot":"","sources":["../../src/api/parse-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-map.d.ts","sourceRoot":"","sources":["../../src/api/parse-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAM,MAAM,eAAe,CAAC;AAqBzC,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IAEX,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IAEd,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,GAAG,CAAC;IAEtB,iCAAiC;IACjC,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,IAAI,KAAA;;;;;;;IAazB,iCAAiC;;;;;;;EA4BpC"}
|
package/dist/api/parse-map.js
CHANGED
package/dist/api/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/api/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAC,4BAAyB;AAKrF,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAGzF,eAAO,MAAM,KAAK,YAA4B,YAAY,KAAG,QAAQ,WAAW,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/api/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAC,4BAAyB;AAKrF,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;AAGzF,eAAO,MAAM,KAAK,YAA4B,YAAY,KAAG,QAAQ,WAAW,CA8B/E,CAAC"}
|
package/dist/api/query.js
CHANGED
|
@@ -2,22 +2,23 @@ import { SOURCE_DEFAULTS } from "../sources/index.js";
|
|
|
2
2
|
import { buildQueryUrl } from "./endpoints.js";
|
|
3
3
|
import { requestWithParameters } from "./request-with-parameters.js";
|
|
4
4
|
export const query = async function (options) {
|
|
5
|
-
const { apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, connectionName, sqlQuery, queryParameters } = options;
|
|
5
|
+
const { apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, clientId = SOURCE_DEFAULTS.clientId, connectionName, sqlQuery, queryParameters } = options;
|
|
6
6
|
const urlParameters = { q: sqlQuery };
|
|
7
7
|
if (queryParameters) {
|
|
8
8
|
urlParameters.queryParameters = JSON.stringify(queryParameters);
|
|
9
9
|
}
|
|
10
10
|
const baseUrl = buildQueryUrl({ apiBaseUrl, connectionName });
|
|
11
11
|
const headers = { Authorization: `Bearer ${options.accessToken}`, ...options.headers };
|
|
12
|
+
const parameters = { client: clientId, ...urlParameters };
|
|
12
13
|
const errorContext = {
|
|
13
14
|
requestType: 'SQL',
|
|
14
15
|
connection: options.connectionName,
|
|
15
16
|
type: 'query',
|
|
16
|
-
source: JSON.stringify(
|
|
17
|
+
source: JSON.stringify(parameters, undefined, 2)
|
|
17
18
|
};
|
|
18
19
|
return await requestWithParameters({
|
|
19
20
|
baseUrl,
|
|
20
|
-
parameters
|
|
21
|
+
parameters,
|
|
21
22
|
headers,
|
|
22
23
|
errorContext
|
|
23
24
|
});
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SCALE_TYPE } from "./layer-map.js";
|
|
2
2
|
export type Format = 'json' | 'geojson' | 'tilejson';
|
|
3
3
|
export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
|
|
4
|
-
export type RequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL';
|
|
4
|
+
export type RequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL' | 'Basemap style';
|
|
5
5
|
export type APIErrorContext = {
|
|
6
6
|
requestType: RequestType;
|
|
7
7
|
mapId?: string;
|
|
@@ -141,5 +141,86 @@ export type MapDataset = {
|
|
|
141
141
|
aggregationResLevel: number | null;
|
|
142
142
|
geoColumn: string;
|
|
143
143
|
};
|
|
144
|
+
export interface CustomStyle {
|
|
145
|
+
url?: string;
|
|
146
|
+
style?: any;
|
|
147
|
+
customAttribution?: string;
|
|
148
|
+
}
|
|
149
|
+
export type KeplerMapConfig = {
|
|
150
|
+
mapState: any;
|
|
151
|
+
mapStyle: {
|
|
152
|
+
styleType: string;
|
|
153
|
+
visibleLayerGroups: Record<string, boolean>;
|
|
154
|
+
};
|
|
155
|
+
visState: {
|
|
156
|
+
layers: MapConfigLayer[];
|
|
157
|
+
};
|
|
158
|
+
layerBlending: any;
|
|
159
|
+
interactionConfig: any;
|
|
160
|
+
customBaseMaps?: {
|
|
161
|
+
customStyle?: CustomStyle;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
export type BasemapType = 'maplibre' | 'google-maps';
|
|
165
|
+
export type Basemap = MapLibreBasemap | GoogleBasemap;
|
|
166
|
+
export type BasemapCommon = {
|
|
167
|
+
/**
|
|
168
|
+
* Type of basemap.
|
|
169
|
+
*/
|
|
170
|
+
type: BasemapType;
|
|
171
|
+
/**
|
|
172
|
+
* Custom attribution for style data if not provided by style definition.
|
|
173
|
+
*/
|
|
174
|
+
attribution?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Properties of the basemap. These properties are specific to the basemap type.
|
|
177
|
+
*/
|
|
178
|
+
props: Record<string, any>;
|
|
179
|
+
};
|
|
180
|
+
export type MapLibreBasemap = BasemapCommon & {
|
|
181
|
+
type: 'maplibre';
|
|
182
|
+
/**
|
|
183
|
+
* MapLibre map properties.
|
|
184
|
+
*
|
|
185
|
+
* Meant to be passed to directly to `maplibregl.Map` object.
|
|
186
|
+
*/
|
|
187
|
+
props: MapLibreBasemapProps;
|
|
188
|
+
/**
|
|
189
|
+
* Layer groups to be displayed in the basemap.
|
|
190
|
+
*/
|
|
191
|
+
visibleLayerGroups?: Record<string, boolean>;
|
|
192
|
+
/**
|
|
193
|
+
* If `style` has been filtered by `visibleLayerGroups` then this property contains original style object, so user
|
|
194
|
+
* can use `applyLayerGroupFilters` again with new settings.
|
|
195
|
+
*/
|
|
196
|
+
rawStyle?: string | Record<string, any>;
|
|
197
|
+
};
|
|
198
|
+
export type MapLibreBasemapProps = {
|
|
199
|
+
style: string | Record<string, any>;
|
|
200
|
+
center: [number, number];
|
|
201
|
+
zoom: number;
|
|
202
|
+
pitch?: number;
|
|
203
|
+
bearing?: number;
|
|
204
|
+
};
|
|
205
|
+
export type GoogleBasemap = BasemapCommon & {
|
|
206
|
+
type: 'google-maps';
|
|
207
|
+
/**
|
|
208
|
+
* Google map properties.
|
|
209
|
+
*
|
|
210
|
+
* Meant to be passed to directly to `google.maps.Map` object.
|
|
211
|
+
*/
|
|
212
|
+
props: GoogleBasemapProps;
|
|
213
|
+
};
|
|
214
|
+
export type GoogleBasemapProps = {
|
|
215
|
+
mapTypeId: string;
|
|
216
|
+
mapId?: string;
|
|
217
|
+
center?: {
|
|
218
|
+
lat: number;
|
|
219
|
+
lng: number;
|
|
220
|
+
};
|
|
221
|
+
zoom?: number;
|
|
222
|
+
tilt?: number;
|
|
223
|
+
heading?: number;
|
|
224
|
+
};
|
|
144
225
|
export {};
|
|
145
226
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,uBAAoB;AAEvC,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC5E,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,uBAAoB;AAEvC,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;AACrD,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,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ACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,IAAI,EAAE,aAAa,CAAC;IAEpB;;;;OAIG;IACH,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAGF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/dist/basemap.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { APIErrorContext, GoogleBasemapProps } from "./api/types.js";
|
|
2
|
+
export declare const CARTO_MAP_STYLES: string[];
|
|
3
|
+
export declare const GOOGLE_BASEMAPS: Record<string, GoogleBasemapProps>;
|
|
4
|
+
type StyleLayerGroupSlug = 'label' | 'road' | 'border' | 'building' | 'water' | 'land';
|
|
5
|
+
type StyleLayerGroup = {
|
|
6
|
+
slug: StyleLayerGroupSlug;
|
|
7
|
+
filter: (layer: any) => boolean;
|
|
8
|
+
defaultVisibility: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const STYLE_LAYER_GROUPS: StyleLayerGroup[];
|
|
11
|
+
export declare function applyLayerGroupFilters(style: any, visibleLayerGroups: Record<StyleLayerGroupSlug, boolean>): any;
|
|
12
|
+
export declare function someLayerGroupsDisabled(visibleLayerGroups?: Record<StyleLayerGroupSlug, boolean>): boolean | undefined;
|
|
13
|
+
export declare function getStyleUrl(styleType: string): string;
|
|
14
|
+
export declare function fetchStyle({ styleUrl, errorContext }: {
|
|
15
|
+
styleUrl: string;
|
|
16
|
+
errorContext?: APIErrorContext;
|
|
17
|
+
}): Promise<any>;
|
|
1
18
|
declare const _default: {
|
|
2
19
|
readonly VOYAGER: string;
|
|
3
20
|
readonly POSITRON: string;
|
package/dist/basemap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basemap.d.ts","sourceRoot":"","sources":["../src/basemap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"basemap.d.ts","sourceRoot":"","sources":["../src/basemap.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,uBAAoB;AAIhE,eAAO,MAAM,gBAAgB,UAAyC,CAAC;AAEvE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CA0B9D,CAAC;AAEF,KAAK,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AACvF,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IAChC,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAAe,EAoC/C,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,KAAK,KAAA,EACL,kBAAkB,EAAE,MAAM,CAAC,mBAAmB,EAAE,OAAO,CAAC,OAkBzD;AAED,wBAAgB,uBAAuB,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,mBAAmB,EAAE,OAAO,CAAC,uBAEhG;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,UAE5C;AAED,wBAAsB,UAAU,CAAC,EAC/B,QAAQ,EACR,YAAY,EACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC,gBAWA;;;;;;;;;AAED,wBAOW"}
|
package/dist/basemap.js
CHANGED
|
@@ -1,9 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
import { CartoAPIError } from "./api/carto-api-error.js";
|
|
2
|
+
const cartoStyleUrlTemplate = 'https://basemaps.cartocdn.com/gl/{basemap}-gl-style/style.json';
|
|
3
|
+
export const CARTO_MAP_STYLES = ['positron', 'dark-matter', 'voyager'];
|
|
4
|
+
export const GOOGLE_BASEMAPS = {
|
|
5
|
+
roadmap: {
|
|
6
|
+
mapTypeId: 'roadmap',
|
|
7
|
+
mapId: '3754c817b510f791'
|
|
8
|
+
},
|
|
9
|
+
'google-positron': {
|
|
10
|
+
mapTypeId: 'roadmap',
|
|
11
|
+
mapId: 'ea84ae4203ef21cd'
|
|
12
|
+
},
|
|
13
|
+
'google-dark-matter': {
|
|
14
|
+
mapTypeId: 'roadmap',
|
|
15
|
+
mapId: '2fccc3b36c22a0e2'
|
|
16
|
+
},
|
|
17
|
+
'google-voyager': {
|
|
18
|
+
mapTypeId: 'roadmap',
|
|
19
|
+
mapId: '885caf1e15bb9ef2'
|
|
20
|
+
},
|
|
21
|
+
satellite: {
|
|
22
|
+
mapTypeId: 'satellite'
|
|
23
|
+
},
|
|
24
|
+
hybrid: {
|
|
25
|
+
mapTypeId: 'hybrid'
|
|
26
|
+
},
|
|
27
|
+
terrain: {
|
|
28
|
+
mapTypeId: 'terrain'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const STYLE_LAYER_GROUPS = [
|
|
32
|
+
{
|
|
33
|
+
slug: 'label',
|
|
34
|
+
filter: ({ id }) => Boolean(id.match(/(?=(label|_label|place-|place_|poi-|poi_|watername_|roadname_|housenumber))/)),
|
|
35
|
+
defaultVisibility: true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
slug: 'road',
|
|
39
|
+
filter: ({ id }) => Boolean(id.match(/(?=(road|railway|tunnel|street|bridge))(?!.*label)/)),
|
|
40
|
+
defaultVisibility: true
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
slug: 'border',
|
|
44
|
+
filter: ({ id }) => Boolean(id.match(/border|boundaries|boundary_/)),
|
|
45
|
+
defaultVisibility: false
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
slug: 'building',
|
|
49
|
+
filter: ({ id }) => Boolean(id.match(/building/)),
|
|
50
|
+
defaultVisibility: true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
slug: 'water',
|
|
54
|
+
filter: ({ id }) => Boolean(id.match(/(?=(water|stream|ferry))/)),
|
|
55
|
+
defaultVisibility: true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
slug: 'land',
|
|
59
|
+
filter: ({ id }) => Boolean(id.match(/(?=(parks|landcover|industrial|sand|hillshade|park_))/)),
|
|
60
|
+
defaultVisibility: true
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
export function applyLayerGroupFilters(style, visibleLayerGroups) {
|
|
64
|
+
if (!Array.isArray(style?.layers)) {
|
|
65
|
+
return style;
|
|
66
|
+
}
|
|
67
|
+
const removedLayerFilters = STYLE_LAYER_GROUPS.filter(lg => !visibleLayerGroups[lg.slug]).map(lg => lg.filter);
|
|
68
|
+
const visibleLayers = style.layers.filter(layer => removedLayerFilters.every(match => !match(layer)));
|
|
69
|
+
return {
|
|
70
|
+
...style,
|
|
71
|
+
layers: visibleLayers
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function someLayerGroupsDisabled(visibleLayerGroups) {
|
|
75
|
+
return visibleLayerGroups && Object.values(visibleLayerGroups).every(Boolean) === false;
|
|
76
|
+
}
|
|
77
|
+
export function getStyleUrl(styleType) {
|
|
78
|
+
return cartoStyleUrlTemplate.replace('{basemap}', styleType);
|
|
79
|
+
}
|
|
80
|
+
export async function fetchStyle({ styleUrl, errorContext }) {
|
|
81
|
+
/* global fetch */
|
|
82
|
+
let response;
|
|
83
|
+
return await fetch(styleUrl, { mode: 'cors' })
|
|
84
|
+
.then(res => {
|
|
85
|
+
response = res;
|
|
86
|
+
return res.json();
|
|
87
|
+
})
|
|
88
|
+
.catch(error => {
|
|
89
|
+
throw new CartoAPIError(error, { ...errorContext, requestType: 'Basemap style' }, response);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
2
92
|
export default {
|
|
3
|
-
VOYAGER:
|
|
4
|
-
POSITRON:
|
|
5
|
-
DARK_MATTER:
|
|
6
|
-
VOYAGER_NOLABELS:
|
|
7
|
-
POSITRON_NOLABELS:
|
|
8
|
-
DARK_MATTER_NOLABELS:
|
|
93
|
+
VOYAGER: getStyleUrl('voyager'),
|
|
94
|
+
POSITRON: getStyleUrl('positron'),
|
|
95
|
+
DARK_MATTER: getStyleUrl('dark-matter'),
|
|
96
|
+
VOYAGER_NOLABELS: getStyleUrl('voyager-nolabels'),
|
|
97
|
+
POSITRON_NOLABELS: getStyleUrl('positron-nolabels'),
|
|
98
|
+
DARK_MATTER_NOLABELS: getStyleUrl('dark-matter-nolabels')
|
|
9
99
|
};
|
|
@@ -1008,7 +1008,7 @@
|
|
|
1008
1008
|
}
|
|
1009
1009
|
|
|
1010
1010
|
// src/layers/schema/carto-raster-tile-loader.ts
|
|
1011
|
-
var VERSION = true ? "9.0.
|
|
1011
|
+
var VERSION = true ? "9.0.15" : "latest";
|
|
1012
1012
|
var id = "cartoRasterTile";
|
|
1013
1013
|
var DEFAULT_OPTIONS = {
|
|
1014
1014
|
cartoRasterTile: {
|
|
@@ -1397,7 +1397,7 @@
|
|
|
1397
1397
|
}
|
|
1398
1398
|
|
|
1399
1399
|
// src/layers/schema/carto-spatial-tile-loader.ts
|
|
1400
|
-
var VERSION = true ? "9.0.
|
|
1400
|
+
var VERSION = true ? "9.0.15" : "latest";
|
|
1401
1401
|
var id = "cartoSpatialTile";
|
|
1402
1402
|
var DEFAULT_OPTIONS = {
|
|
1403
1403
|
cartoSpatialTile: {
|
|
@@ -1625,7 +1625,7 @@
|
|
|
1625
1625
|
}
|
|
1626
1626
|
|
|
1627
1627
|
// src/layers/schema/carto-vector-tile-loader.ts
|
|
1628
|
-
var VERSION = true ? "9.0.
|
|
1628
|
+
var VERSION = true ? "9.0.15" : "latest";
|
|
1629
1629
|
var id = "cartoVectorTile";
|
|
1630
1630
|
var DEFAULT_OPTIONS = {
|
|
1631
1631
|
cartoVectorTile: {
|