@deck.gl/carto 9.1.12 → 9.2.0-alpha.2
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/fetch-map.d.ts +13 -45
- package/dist/api/fetch-map.d.ts.map +1 -1
- package/dist/api/fetch-map.js +45 -202
- package/dist/api/fetch-map.js.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/cartoPropertiesTile-worker.js +1 -1
- 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 +14497 -12442
- package/dist/index.cjs +24 -848
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -18
- package/dist/index.js.map +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js +1 -1
- package/dist/layers/schema/carto-properties-tile-loader.js.map +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js +1 -1
- package/dist/layers/schema/carto-raster-tile-loader.js.map +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js +1 -1
- package/dist/layers/schema/carto-spatial-tile-loader.js.map +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js +1 -1
- package/dist/layers/schema/carto-vector-tile-loader.js.map +1 -1
- package/dist/layers/schema/spatialjson-utils.d.ts.map +1 -1
- package/dist/layers/schema/spatialjson-utils.js.map +1 -1
- package/dist/layers/vector-tile-layer.d.ts.map +1 -1
- package/dist/layers/vector-tile-layer.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist.min.js +10 -27
- package/package.json +6 -6
- package/src/api/fetch-map.ts +54 -341
- package/src/api/index.ts +1 -1
- package/src/index.ts +1 -74
- package/src/layers/schema/spatialjson-utils.ts +0 -1
- package/src/layers/vector-tile-layer.ts +1 -2
- package/src/utils.ts +1 -6
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.
|
|
6
|
+
"version": "9.2.0-alpha.2",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@carto/api-client": "^0.
|
|
45
|
+
"@carto/api-client": "^0.5.6",
|
|
46
46
|
"@loaders.gl/compression": "^4.2.0",
|
|
47
47
|
"@loaders.gl/gis": "^4.2.0",
|
|
48
48
|
"@loaders.gl/loader-utils": "^4.2.0",
|
|
49
49
|
"@loaders.gl/mvt": "^4.2.0",
|
|
50
50
|
"@loaders.gl/schema": "^4.2.0",
|
|
51
51
|
"@loaders.gl/tiles": "^4.2.0",
|
|
52
|
-
"@luma.gl/core": "^9.1.
|
|
53
|
-
"@luma.gl/shadertools": "^9.1.
|
|
52
|
+
"@luma.gl/core": "^9.1.9",
|
|
53
|
+
"@luma.gl/shadertools": "^9.1.9",
|
|
54
54
|
"@math.gl/web-mercator": "^4.1.0",
|
|
55
55
|
"@types/d3-array": "^3.0.2",
|
|
56
56
|
"@types/d3-color": "^1.4.2",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@deck.gl/geo-layers": "^9.1.0",
|
|
74
74
|
"@deck.gl/layers": "^9.1.0",
|
|
75
75
|
"@loaders.gl/core": "^4.2.0",
|
|
76
|
-
"@luma.gl/core": "^9.1.
|
|
76
|
+
"@luma.gl/core": "^9.1.9"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "f9ca91bb15011ff5552ca8966b4207ada03a08fc"
|
|
79
79
|
}
|
package/src/api/fetch-map.ts
CHANGED
|
@@ -1,359 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {_ConstructorOf, Layer} from '@deck.gl/core';
|
|
2
|
+
import ClusterTileLayer from '../layers/cluster-tile-layer';
|
|
3
|
+
import H3TileLayer from '../layers/h3-tile-layer';
|
|
4
|
+
import HeatmapTileLayer from '../layers/heatmap-tile-layer';
|
|
5
|
+
import VectorTileLayer from '../layers/vector-tile-layer';
|
|
6
|
+
import QuadbinTileLayer from '../layers/quadbin-tile-layer';
|
|
7
|
+
import RasterTileLayer from '../layers/raster-tile-layer';
|
|
6
8
|
|
|
7
9
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
TilejsonResult,
|
|
14
|
-
Format,
|
|
15
|
-
MapType,
|
|
16
|
-
QueryParameters,
|
|
17
|
-
SourceOptions,
|
|
18
|
-
buildPublicMapUrl,
|
|
19
|
-
buildStatsUrl,
|
|
20
|
-
h3QuerySource,
|
|
21
|
-
h3TableSource,
|
|
22
|
-
quadbinQuerySource,
|
|
23
|
-
quadbinTableSource,
|
|
24
|
-
vectorQuerySource,
|
|
25
|
-
vectorTableSource,
|
|
26
|
-
vectorTilesetSource,
|
|
27
|
-
requestWithParameters
|
|
10
|
+
fetchMap as _fetchMap,
|
|
11
|
+
FetchMapOptions as _FetchMapOptions,
|
|
12
|
+
FetchMapResult as _FetchMapResult,
|
|
13
|
+
LayerDescriptor,
|
|
14
|
+
LayerType
|
|
28
15
|
} from '@carto/api-client';
|
|
29
|
-
import {ParseMapResult, parseMap} from './parse-map';
|
|
30
|
-
import {assert} from '../utils';
|
|
31
|
-
import type {Basemap} from './types';
|
|
32
|
-
import {fetchBasemapProps} from './basemap';
|
|
33
16
|
|
|
34
|
-
type
|
|
35
|
-
|
|
36
|
-
type: MapType;
|
|
37
|
-
source: string;
|
|
38
|
-
cache?: number;
|
|
39
|
-
connectionName: string;
|
|
40
|
-
geoColumn: string;
|
|
41
|
-
data: TilejsonResult | GeojsonResult | JsonResult;
|
|
42
|
-
columns: string[];
|
|
43
|
-
format: Format;
|
|
44
|
-
aggregationExp: string;
|
|
45
|
-
aggregationResLevel: number;
|
|
46
|
-
queryParameters: QueryParameters;
|
|
17
|
+
export type FetchMapResult = Omit<_FetchMapResult, 'layers'> & {
|
|
18
|
+
layers: Layer[];
|
|
47
19
|
};
|
|
48
20
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
aggregationExp,
|
|
54
|
-
aggregationResLevel,
|
|
55
|
-
connectionName,
|
|
56
|
-
columns,
|
|
57
|
-
format,
|
|
58
|
-
geoColumn,
|
|
59
|
-
source,
|
|
60
|
-
type,
|
|
61
|
-
queryParameters
|
|
62
|
-
} = dataset;
|
|
63
|
-
|
|
64
|
-
const cache: {value?: number} = {};
|
|
65
|
-
const globalOptions = {
|
|
66
|
-
...context,
|
|
67
|
-
cache,
|
|
68
|
-
connectionName,
|
|
69
|
-
format
|
|
70
|
-
} as SourceOptions;
|
|
21
|
+
export type FetchMapOptions = Omit<_FetchMapOptions, 'onNewData'> & {
|
|
22
|
+
onNewData?: (result: FetchMapResult) => void;
|
|
23
|
+
};
|
|
71
24
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
queryParameters
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
} else if (spatialDataType === 'h3') {
|
|
91
|
-
const options = {...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn};
|
|
92
|
-
if (type === 'table') {
|
|
93
|
-
dataset.data = await h3TableSource({...options, tableName: source});
|
|
94
|
-
} else if (type === 'query') {
|
|
95
|
-
dataset.data = await h3QuerySource({...options, sqlQuery: source, queryParameters});
|
|
96
|
-
}
|
|
97
|
-
} else if (spatialDataType === 'quadbin') {
|
|
98
|
-
const options = {...globalOptions, aggregationExp, aggregationResLevel, spatialDataColumn};
|
|
99
|
-
if (type === 'table') {
|
|
100
|
-
dataset.data = await quadbinTableSource({...options, tableName: source});
|
|
101
|
-
} else if (type === 'query') {
|
|
102
|
-
dataset.data = await quadbinQuerySource({...options, sqlQuery: source, queryParameters});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
25
|
+
// Layer factory to create deck.gl layers from layer descriptors
|
|
26
|
+
const layerClasses: Record<LayerType, _ConstructorOf<Layer>> = {
|
|
27
|
+
clusterTile: ClusterTileLayer,
|
|
28
|
+
h3: H3TileLayer,
|
|
29
|
+
heatmapTile: HeatmapTileLayer,
|
|
30
|
+
mvt: VectorTileLayer,
|
|
31
|
+
quadbin: QuadbinTileLayer,
|
|
32
|
+
raster: RasterTileLayer,
|
|
33
|
+
tileset: VectorTileLayer
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
export function LayerFactory(descriptor: LayerDescriptor): Layer {
|
|
37
|
+
const LayerClass = layerClasses[descriptor.type];
|
|
38
|
+
if (!LayerClass) {
|
|
39
|
+
throw new Error(`No layer class found for type: ${descriptor.type}`);
|
|
105
40
|
}
|
|
106
|
-
|
|
107
|
-
if (cache.value) {
|
|
108
|
-
cacheChanged = dataset.cache !== cache.value;
|
|
109
|
-
dataset.cache = cache.value;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return cacheChanged;
|
|
41
|
+
return new LayerClass(descriptor.props);
|
|
113
42
|
}
|
|
114
43
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
requestType: 'Tile stats',
|
|
120
|
-
connection: connectionName,
|
|
121
|
-
type,
|
|
122
|
-
source
|
|
44
|
+
function createResult(result: _FetchMapResult): FetchMapResult {
|
|
45
|
+
return {
|
|
46
|
+
...result,
|
|
47
|
+
layers: result.layers.map(descriptor => LayerFactory(descriptor))
|
|
123
48
|
};
|
|
124
|
-
if (!('tilestats' in data)) {
|
|
125
|
-
throw new CartoAPIError(new Error(`Invalid dataset for tilestats: ${id}`), errorContext);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const baseUrl = buildStatsUrl({attribute, apiBaseUrl, ...dataset});
|
|
129
|
-
const client = new URLSearchParams(data.tiles[0]).get('client');
|
|
130
|
-
const headers = {Authorization: `Bearer ${context.accessToken}`};
|
|
131
|
-
const parameters: Record<string, string> = {};
|
|
132
|
-
if (client) {
|
|
133
|
-
parameters.client = client;
|
|
134
|
-
}
|
|
135
|
-
if (type === 'query') {
|
|
136
|
-
parameters.q = source;
|
|
137
|
-
if (queryParameters) {
|
|
138
|
-
parameters.queryParameters = JSON.stringify(queryParameters);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const stats = await requestWithParameters({
|
|
142
|
-
baseUrl,
|
|
143
|
-
headers,
|
|
144
|
-
parameters,
|
|
145
|
-
errorContext,
|
|
146
|
-
maxLengthURL: context.maxLengthURL
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Replace tilestats for attribute with value from API
|
|
150
|
-
const {attributes} = data.tilestats.layers[0];
|
|
151
|
-
const index = attributes.findIndex(d => d.attribute === attribute);
|
|
152
|
-
attributes[index] = stats;
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async function fillInMapDatasets({datasets}: {datasets: Dataset[]}, context: _FetchMapContext) {
|
|
157
|
-
const promises = datasets.map(dataset => _fetchMapDataset(dataset, context));
|
|
158
|
-
return await Promise.all(promises);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function fillInTileStats(
|
|
162
|
-
{datasets, keplerMapConfig}: {datasets: Dataset[]; keplerMapConfig: any},
|
|
163
|
-
context: _FetchMapContext
|
|
164
|
-
) {
|
|
165
|
-
const attributes: {attribute: string; dataset: any}[] = [];
|
|
166
|
-
const {layers} = keplerMapConfig.config.visState;
|
|
167
|
-
for (const layer of layers) {
|
|
168
|
-
for (const channel of Object.keys(layer.visualChannels)) {
|
|
169
|
-
const attribute = layer.visualChannels[channel]?.name;
|
|
170
|
-
if (attribute) {
|
|
171
|
-
const dataset = datasets.find(d => d.id === layer.config.dataId);
|
|
172
|
-
if (dataset && dataset.type !== 'tileset' && (dataset.data as TilejsonResult).tilestats) {
|
|
173
|
-
// Only fetch stats for QUERY & TABLE map types
|
|
174
|
-
attributes.push({attribute, dataset});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// Remove duplicates to avoid repeated requests
|
|
180
|
-
const filteredAttributes: {attribute: string; dataset: any}[] = [];
|
|
181
|
-
for (const a of attributes) {
|
|
182
|
-
if (
|
|
183
|
-
!filteredAttributes.find(
|
|
184
|
-
({attribute, dataset}) => attribute === a.attribute && dataset === a.dataset
|
|
185
|
-
)
|
|
186
|
-
) {
|
|
187
|
-
filteredAttributes.push(a);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const promises = filteredAttributes.map(({attribute, dataset}) =>
|
|
192
|
-
_fetchTilestats(attribute, dataset, context)
|
|
193
|
-
);
|
|
194
|
-
return await Promise.all(promises);
|
|
195
49
|
}
|
|
196
50
|
|
|
197
|
-
export type FetchMapOptions = {
|
|
198
|
-
/**
|
|
199
|
-
* CARTO platform access token. Only required for private maps.
|
|
200
|
-
*/
|
|
201
|
-
accessToken?: string;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Base URL of the CARTO Maps API.
|
|
205
|
-
*
|
|
206
|
-
* Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com`
|
|
207
|
-
*
|
|
208
|
-
* @default https://gcp-us-east1.api.carto.com
|
|
209
|
-
*/
|
|
210
|
-
apiBaseUrl?: string;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Identifier of map created in CARTO Builder.
|
|
214
|
-
*/
|
|
215
|
-
cartoMapId: string;
|
|
216
|
-
clientId?: string;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Custom HTTP headers added to map instantiation and data requests.
|
|
220
|
-
*/
|
|
221
|
-
headers?: Record<string, string>;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Interval in seconds at which to autoRefresh the data. If provided, `onNewData` must also be provided.
|
|
225
|
-
*/
|
|
226
|
-
autoRefresh?: number;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Callback function that will be invoked whenever data in layers is changed. If provided, `autoRefresh` must also be provided.
|
|
230
|
-
*/
|
|
231
|
-
onNewData?: (map: any) => void;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Maximum URL character length. Above this limit, requests use POST.
|
|
235
|
-
* Used to avoid browser and CDN limits.
|
|
236
|
-
* @default {@link DEFAULT_MAX_LENGTH_URL}
|
|
237
|
-
*/
|
|
238
|
-
maxLengthURL?: number;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
51
|
/**
|
|
242
|
-
*
|
|
52
|
+
* fetchMap is a wrapper around the @carto/api-client fetchMap function, with additions for convenience and backward-compatibility.
|
|
53
|
+
* Where @carto/api-client fetchMap returns layer props, @deck.gl/carto fetchMap returns Layer instances ready for use.
|
|
54
|
+
* For greater control, use the @carto/api-client fetchMap function directly and use LayerFactory to create layers manually.
|
|
243
55
|
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
stopAutoRefresh?: () => void;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/* eslint-disable max-statements */
|
|
258
|
-
export async function fetchMap({
|
|
259
|
-
accessToken,
|
|
260
|
-
apiBaseUrl = DEFAULT_API_BASE_URL,
|
|
261
|
-
cartoMapId,
|
|
262
|
-
clientId,
|
|
263
|
-
headers,
|
|
264
|
-
autoRefresh,
|
|
265
|
-
onNewData,
|
|
266
|
-
maxLengthURL
|
|
267
|
-
}: FetchMapOptions): Promise<FetchMapResult> {
|
|
268
|
-
assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
|
|
269
|
-
|
|
270
|
-
if (accessToken) {
|
|
271
|
-
headers = {Authorization: `Bearer ${accessToken}`, ...headers};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (autoRefresh || onNewData) {
|
|
275
|
-
assert(onNewData, 'Must define `onNewData` when using autoRefresh');
|
|
276
|
-
assert(typeof onNewData === 'function', '`onNewData` must be a function');
|
|
277
|
-
assert(
|
|
278
|
-
typeof autoRefresh === 'number' && autoRefresh > 0,
|
|
279
|
-
'`autoRefresh` must be a positive number'
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const baseUrl = buildPublicMapUrl({apiBaseUrl, cartoMapId});
|
|
284
|
-
const errorContext: APIErrorContext = {requestType: 'Public map', mapId: cartoMapId};
|
|
285
|
-
const map = await requestWithParameters({baseUrl, headers, errorContext, maxLengthURL});
|
|
286
|
-
const context: _FetchMapContext = {
|
|
287
|
-
accessToken: map.token || accessToken,
|
|
288
|
-
apiBaseUrl,
|
|
289
|
-
clientId,
|
|
290
|
-
headers,
|
|
291
|
-
maxLengthURL
|
|
56
|
+
export async function fetchMap(options: FetchMapOptions): Promise<FetchMapResult> {
|
|
57
|
+
const {onNewData, ...rest} = options;
|
|
58
|
+
const _options: _FetchMapOptions = {
|
|
59
|
+
...rest,
|
|
60
|
+
onNewData:
|
|
61
|
+
typeof onNewData === 'function'
|
|
62
|
+
? result => {
|
|
63
|
+
onNewData(createResult(result));
|
|
64
|
+
}
|
|
65
|
+
: undefined
|
|
292
66
|
};
|
|
293
67
|
|
|
294
|
-
//
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
299
|
-
const intervalId = setInterval(async () => {
|
|
300
|
-
const changed = await fillInMapDatasets(map, {
|
|
301
|
-
...context,
|
|
302
|
-
headers: {
|
|
303
|
-
...headers,
|
|
304
|
-
'If-Modified-Since': new Date().toUTCString()
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
if (onNewData && changed.some(v => v === true)) {
|
|
308
|
-
onNewData(parseMap(map));
|
|
309
|
-
}
|
|
310
|
-
}, autoRefresh * 1000);
|
|
311
|
-
stopAutoRefresh = () => {
|
|
312
|
-
clearInterval(intervalId);
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(
|
|
317
|
-
({type}) => type === 'geojson' || type === 'point'
|
|
318
|
-
);
|
|
319
|
-
const geojsonDatasetIds = geojsonLayers.map(({config}) => config.dataId);
|
|
320
|
-
map.datasets.forEach(dataset => {
|
|
321
|
-
if (geojsonDatasetIds.includes(dataset.id)) {
|
|
322
|
-
const {config} = geojsonLayers.find(({config}) => config.dataId === dataset.id);
|
|
323
|
-
dataset.format = 'geojson';
|
|
324
|
-
// Support for very old maps. geoColumn was not stored in the past
|
|
325
|
-
if (!dataset.geoColumn && config.columns.geojson) {
|
|
326
|
-
dataset.geoColumn = config.columns.geojson;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
const [basemap] = await Promise.all([
|
|
332
|
-
fetchBasemapProps({config: map.keplerMapConfig.config, errorContext}),
|
|
333
|
-
|
|
334
|
-
// Mutates map.datasets so that dataset.data contains data
|
|
335
|
-
fillInMapDatasets(map, context)
|
|
336
|
-
]);
|
|
337
|
-
|
|
338
|
-
// Mutates attributes in visualChannels to contain tile stats
|
|
339
|
-
await fillInTileStats(map, context);
|
|
340
|
-
|
|
341
|
-
const out = {...parseMap(map), basemap, ...{stopAutoRefresh}};
|
|
342
|
-
|
|
343
|
-
const textLayers = out.layers.filter(layer => {
|
|
344
|
-
const pointType = layer.props.pointType || '';
|
|
345
|
-
return pointType.includes('text');
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
/* global FontFace, window, document */
|
|
349
|
-
if (textLayers.length && window.FontFace && !document.fonts.check('12px Inter')) {
|
|
350
|
-
// Fetch font needed for labels
|
|
351
|
-
const font = new FontFace(
|
|
352
|
-
'Inter',
|
|
353
|
-
'url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2)'
|
|
354
|
-
);
|
|
355
|
-
await font.load().then(f => document.fonts.add(f));
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return out;
|
|
68
|
+
// For backwards compatibility, provide a shim for the old API
|
|
69
|
+
const _result: _FetchMapResult = await _fetchMap(_options);
|
|
70
|
+
const result: FetchMapResult = createResult(_result);
|
|
71
|
+
return result;
|
|
359
72
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
export {fetchMap} from './fetch-map';
|
|
5
|
+
export {fetchMap, LayerFactory} from './fetch-map';
|
|
6
6
|
export type {FetchMapOptions, FetchMapResult} from './fetch-map';
|
|
7
7
|
export type {Basemap, MapLibreBasemap, GoogleBasemap} from './types';
|
package/src/index.ts
CHANGED
|
@@ -61,7 +61,7 @@ export {
|
|
|
61
61
|
export {default as colorBins} from './style/color-bins-style';
|
|
62
62
|
export {default as colorCategories} from './style/color-categories-style';
|
|
63
63
|
export {default as colorContinuous} from './style/color-continuous-style';
|
|
64
|
-
export {fetchMap} from './api/
|
|
64
|
+
export {fetchMap, LayerFactory} from './api/fetch-map';
|
|
65
65
|
export {fetchBasemapProps} from './api/basemap';
|
|
66
66
|
export type {
|
|
67
67
|
FetchMapOptions,
|
|
@@ -70,76 +70,3 @@ export type {
|
|
|
70
70
|
MapLibreBasemap as _MapLibreBasemap,
|
|
71
71
|
GoogleBasemap as _GoogleBasemap
|
|
72
72
|
} from './api/index';
|
|
73
|
-
|
|
74
|
-
// TODO(v10): Consider removing re-exports from '@carto/api-client' below.
|
|
75
|
-
|
|
76
|
-
import {
|
|
77
|
-
boundaryQuerySource,
|
|
78
|
-
boundaryTableSource,
|
|
79
|
-
h3QuerySource,
|
|
80
|
-
h3TableSource,
|
|
81
|
-
h3TilesetSource,
|
|
82
|
-
rasterSource,
|
|
83
|
-
quadbinQuerySource,
|
|
84
|
-
quadbinTableSource,
|
|
85
|
-
quadbinTilesetSource,
|
|
86
|
-
vectorQuerySource,
|
|
87
|
-
vectorTableSource,
|
|
88
|
-
vectorTilesetSource
|
|
89
|
-
} from '@carto/api-client';
|
|
90
|
-
|
|
91
|
-
export const CARTO_SOURCES = {
|
|
92
|
-
boundaryQuerySource,
|
|
93
|
-
boundaryTableSource,
|
|
94
|
-
h3QuerySource,
|
|
95
|
-
h3TableSource,
|
|
96
|
-
h3TilesetSource,
|
|
97
|
-
rasterSource,
|
|
98
|
-
quadbinQuerySource,
|
|
99
|
-
quadbinTableSource,
|
|
100
|
-
quadbinTilesetSource,
|
|
101
|
-
vectorQuerySource,
|
|
102
|
-
vectorTableSource,
|
|
103
|
-
vectorTilesetSource
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export {
|
|
107
|
-
boundaryQuerySource,
|
|
108
|
-
boundaryTableSource,
|
|
109
|
-
h3QuerySource,
|
|
110
|
-
h3TableSource,
|
|
111
|
-
h3TilesetSource,
|
|
112
|
-
rasterSource,
|
|
113
|
-
quadbinQuerySource,
|
|
114
|
-
quadbinTableSource,
|
|
115
|
-
quadbinTilesetSource,
|
|
116
|
-
vectorQuerySource,
|
|
117
|
-
vectorTableSource,
|
|
118
|
-
vectorTilesetSource,
|
|
119
|
-
query,
|
|
120
|
-
CartoAPIError,
|
|
121
|
-
SOURCE_DEFAULTS
|
|
122
|
-
} from '@carto/api-client';
|
|
123
|
-
|
|
124
|
-
export type {
|
|
125
|
-
GeojsonResult,
|
|
126
|
-
JsonResult,
|
|
127
|
-
TilejsonResult,
|
|
128
|
-
SourceOptions,
|
|
129
|
-
QuerySourceOptions,
|
|
130
|
-
TableSourceOptions,
|
|
131
|
-
TilesetSourceOptions,
|
|
132
|
-
BoundaryQuerySourceOptions,
|
|
133
|
-
BoundaryTableSourceOptions,
|
|
134
|
-
H3QuerySourceOptions,
|
|
135
|
-
H3TableSourceOptions,
|
|
136
|
-
H3TilesetSourceOptions,
|
|
137
|
-
RasterSourceOptions,
|
|
138
|
-
QuadbinQuerySourceOptions,
|
|
139
|
-
QuadbinTableSourceOptions,
|
|
140
|
-
QuadbinTilesetSourceOptions,
|
|
141
|
-
VectorQuerySourceOptions,
|
|
142
|
-
VectorTableSourceOptions,
|
|
143
|
-
VectorTilesetSourceOptions,
|
|
144
|
-
QueryParameters
|
|
145
|
-
} from '@carto/api-client';
|
|
@@ -6,7 +6,6 @@ import {bigIntToHex} from 'quadbin';
|
|
|
6
6
|
import {BinaryPointFeature} from '@loaders.gl/schema';
|
|
7
7
|
|
|
8
8
|
export type IndexScheme = 'h3' | 'quadbin';
|
|
9
|
-
type TypedArray = Float32Array | Float64Array;
|
|
10
9
|
|
|
11
10
|
export type Indices = {value: BigUint64Array};
|
|
12
11
|
export type NumericProps = BinaryPointFeature['numericProps'];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {registerLoaders} from '@loaders.gl/core';
|
|
6
|
-
import {
|
|
6
|
+
import {BinaryPointFeature} from '@loaders.gl/schema';
|
|
7
7
|
import CartoPropertiesTileLoader from './schema/carto-properties-tile-loader';
|
|
8
8
|
import CartoVectorTileLoader from './schema/carto-vector-tile-loader';
|
|
9
9
|
registerLoaders([CartoPropertiesTileLoader, CartoVectorTileLoader]);
|
|
@@ -13,7 +13,6 @@ import {ClipExtension, CollisionFilterExtension} from '@deck.gl/extensions';
|
|
|
13
13
|
import {
|
|
14
14
|
MVTLayer,
|
|
15
15
|
MVTLayerProps,
|
|
16
|
-
TileLayer,
|
|
17
16
|
_getURLFromTemplate,
|
|
18
17
|
_Tile2DHeader,
|
|
19
18
|
_TileLoadProps as TileLoadProps,
|
package/src/utils.ts
CHANGED
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
BinaryAttribute,
|
|
7
|
-
BinaryFeature,
|
|
8
|
-
BinaryFeatureCollection,
|
|
9
|
-
BinaryPointFeature
|
|
10
|
-
} from '@loaders.gl/schema';
|
|
5
|
+
import {BinaryFeatureCollection, BinaryPointFeature} from '@loaders.gl/schema';
|
|
11
6
|
import {log} from '@deck.gl/core';
|
|
12
7
|
import type {Properties, NumericProps} from './layers/schema/spatialjson-utils';
|
|
13
8
|
|