@deck.gl/carto 8.7.0-beta.6 → 8.7.1
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/dist.dev.js +39 -30
- package/dist/es5/api/maps-v3-client.js +16 -7
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +21 -18
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/layers/carto-tile-layer.js +8 -7
- package/dist/es5/layers/carto-tile-layer.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +13 -1
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/layers/carto-layer.js +16 -17
- package/dist/esm/layers/carto-layer.js.map +1 -1
- package/dist/esm/layers/carto-tile-layer.js +8 -8
- package/dist/esm/layers/carto-tile-layer.js.map +1 -1
- package/dist.min.js +3 -3
- package/package.json +2 -2
- package/src/api/maps-v3-client.ts +18 -2
- package/src/layers/carto-layer.js +17 -14
- package/src/layers/carto-tile-layer.js +11 -8
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/carto",
|
|
3
3
|
"description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "8.7.
|
|
5
|
+
"version": "8.7.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"@deck.gl/layers": "^8.0.0",
|
|
57
57
|
"@loaders.gl/core": "^3.1.5"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "8a2f488c640bbf80982c684e7fd741982afe1d81"
|
|
60
60
|
}
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
MapInstantiation,
|
|
11
11
|
MapType,
|
|
12
12
|
MAP_TYPES,
|
|
13
|
-
SchemaField
|
|
13
|
+
SchemaField,
|
|
14
|
+
TileFormat,
|
|
15
|
+
TILE_FORMATS
|
|
14
16
|
} from './maps-api-common';
|
|
15
17
|
import {parseMap} from './parseMap';
|
|
16
18
|
import {log} from '@deck.gl/core';
|
|
@@ -111,6 +113,7 @@ type FetchLayerDataParams = {
|
|
|
111
113
|
schema?: boolean;
|
|
112
114
|
clientId?: string;
|
|
113
115
|
format?: Format;
|
|
116
|
+
formatTiles?: TileFormat;
|
|
114
117
|
};
|
|
115
118
|
|
|
116
119
|
/**
|
|
@@ -208,6 +211,7 @@ export async function fetchLayerData({
|
|
|
208
211
|
geoColumn,
|
|
209
212
|
columns,
|
|
210
213
|
format,
|
|
214
|
+
formatTiles,
|
|
211
215
|
schema,
|
|
212
216
|
clientId
|
|
213
217
|
}: FetchLayerDataParams): Promise<FetchLayerDataResult> {
|
|
@@ -221,6 +225,7 @@ export async function fetchLayerData({
|
|
|
221
225
|
geoColumn,
|
|
222
226
|
columns,
|
|
223
227
|
format,
|
|
228
|
+
formatTiles,
|
|
224
229
|
schema,
|
|
225
230
|
clientId
|
|
226
231
|
});
|
|
@@ -242,6 +247,7 @@ async function _fetchDataUrl({
|
|
|
242
247
|
geoColumn,
|
|
243
248
|
columns,
|
|
244
249
|
format,
|
|
250
|
+
formatTiles,
|
|
245
251
|
schema,
|
|
246
252
|
clientId
|
|
247
253
|
}: FetchLayerDataParams) {
|
|
@@ -288,6 +294,14 @@ async function _fetchDataUrl({
|
|
|
288
294
|
assert(url && mapFormat, 'Unsupported data formats received from backend.');
|
|
289
295
|
}
|
|
290
296
|
|
|
297
|
+
if (format === FORMATS.TILEJSON && formatTiles) {
|
|
298
|
+
log.assert(
|
|
299
|
+
Object.values(TILE_FORMATS).includes(formatTiles),
|
|
300
|
+
`Invalid value for formatTiles: ${formatTiles}. Use value from TILE_FORMATS`
|
|
301
|
+
);
|
|
302
|
+
url += `&${encodeParameter('formatTiles', formatTiles)}`;
|
|
303
|
+
}
|
|
304
|
+
|
|
291
305
|
const {accessToken} = localCreds;
|
|
292
306
|
return {url, accessToken, mapFormat, metadata};
|
|
293
307
|
}
|
|
@@ -324,11 +338,13 @@ async function _fetchMapDataset(
|
|
|
324
338
|
credentials: CloudNativeCredentials,
|
|
325
339
|
clientId?: string
|
|
326
340
|
) {
|
|
341
|
+
const {connectionName: connection, columns, geoColumn, source, type} = dataset;
|
|
327
342
|
// First fetch metadata
|
|
328
|
-
const {connectionName: connection, source, type} = dataset;
|
|
329
343
|
const {url, mapFormat} = await _fetchDataUrl({
|
|
330
344
|
credentials: {...credentials, accessToken},
|
|
331
345
|
connection,
|
|
346
|
+
columns,
|
|
347
|
+
geoColumn,
|
|
332
348
|
source,
|
|
333
349
|
type,
|
|
334
350
|
clientId
|
|
@@ -92,8 +92,10 @@ export default class CartoLayer extends CompositeLayer {
|
|
|
92
92
|
changeFlags.dataChanged ||
|
|
93
93
|
props.connection !== oldProps.connection ||
|
|
94
94
|
props.geoColumn !== oldProps.geoColumn ||
|
|
95
|
-
|
|
95
|
+
props.format !== oldProps.format ||
|
|
96
|
+
props.formatTiles !== oldProps.formatTiles ||
|
|
96
97
|
props.type !== oldProps.type ||
|
|
98
|
+
JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||
|
|
97
99
|
JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);
|
|
98
100
|
|
|
99
101
|
if (shouldUpdateData) {
|
|
@@ -126,24 +128,29 @@ export default class CartoLayer extends CompositeLayer {
|
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
_getSubLayerAndProps() {
|
|
130
132
|
const {data, format, apiVersion} = this.state;
|
|
131
133
|
|
|
134
|
+
const {uniqueIdProperty} = defaultProps;
|
|
135
|
+
const props = {uniqueIdProperty, ...this.props};
|
|
136
|
+
delete props.data;
|
|
137
|
+
|
|
132
138
|
if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {
|
|
133
|
-
return MVTLayer;
|
|
139
|
+
return [MVTLayer, props];
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
if (format === FORMATS.TILEJSON) {
|
|
137
143
|
/* global URL */
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
TILE_FORMATS.MVT;
|
|
142
|
-
|
|
144
|
+
const tileUrl = new URL(data.tiles[0]);
|
|
145
|
+
|
|
146
|
+
props.formatTiles =
|
|
147
|
+
props.formatTiles || tileUrl.searchParams.get('formatTiles') || TILE_FORMATS.MVT;
|
|
148
|
+
|
|
149
|
+
return props.formatTiles === TILE_FORMATS.MVT ? [MVTLayer, props] : [CartoTileLayer, props];
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
// It's a geojson layer
|
|
146
|
-
return GeoJsonLayer;
|
|
153
|
+
return [GeoJsonLayer, props];
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
renderLayers() {
|
|
@@ -153,11 +160,7 @@ export default class CartoLayer extends CompositeLayer {
|
|
|
153
160
|
|
|
154
161
|
const {updateTriggers} = this.props;
|
|
155
162
|
|
|
156
|
-
const layer = this.
|
|
157
|
-
|
|
158
|
-
const {formatTiles, uniqueIdProperty} = defaultProps;
|
|
159
|
-
const props = {formatTiles, uniqueIdProperty, ...this.props};
|
|
160
|
-
delete props.data;
|
|
163
|
+
const [layer, props] = this._getSubLayerAndProps();
|
|
161
164
|
|
|
162
165
|
// eslint-disable-next-line new-cap
|
|
163
166
|
return new layer(
|
|
@@ -48,6 +48,8 @@ function parseCartoTile(arrayBuffer, options) {
|
|
|
48
48
|
return data;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const defaultTileFormat = TILE_FORMATS.BINARY;
|
|
52
|
+
|
|
51
53
|
const CartoTileLoader = {
|
|
52
54
|
name: 'CARTO Tile',
|
|
53
55
|
id: 'cartoTile',
|
|
@@ -60,15 +62,20 @@ const CartoTileLoader = {
|
|
|
60
62
|
parseSync: parseCartoTile,
|
|
61
63
|
options: {
|
|
62
64
|
cartoTile: {
|
|
63
|
-
|
|
64
|
-
formatTiles: TILE_FORMATS.GEOJSON
|
|
65
|
+
formatTiles: defaultTileFormat
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
};
|
|
68
69
|
|
|
70
|
+
const defaultProps = {
|
|
71
|
+
...MVTLayer.defaultProps,
|
|
72
|
+
formatTiles: defaultTileFormat,
|
|
73
|
+
loaders: [CartoTileLoader]
|
|
74
|
+
};
|
|
75
|
+
|
|
69
76
|
export default class CartoTileLayer extends MVTLayer {
|
|
70
77
|
getTileData(tile) {
|
|
71
|
-
|
|
78
|
+
const url = _getURLFromTemplate(this.state.data, tile);
|
|
72
79
|
if (!url) {
|
|
73
80
|
return Promise.reject('Invalid URL');
|
|
74
81
|
}
|
|
@@ -87,10 +94,6 @@ export default class CartoTileLayer extends MVTLayer {
|
|
|
87
94
|
Object.values(TILE_FORMATS).includes(formatTiles),
|
|
88
95
|
`Invalid value for formatTiles: ${formatTiles}. Use value from TILE_FORMATS`
|
|
89
96
|
);
|
|
90
|
-
// eslint-disable-next-line no-undef
|
|
91
|
-
const newUrl = new URL(url);
|
|
92
|
-
newUrl.searchParams.set('formatTiles', formatTiles);
|
|
93
|
-
url = newUrl.toString();
|
|
94
97
|
loadOptions.cartoTile = {formatTiles};
|
|
95
98
|
}
|
|
96
99
|
|
|
@@ -118,4 +121,4 @@ export default class CartoTileLayer extends MVTLayer {
|
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
CartoTileLayer.layerName = 'CartoTileLayer';
|
|
121
|
-
CartoTileLayer.defaultProps =
|
|
124
|
+
CartoTileLayer.defaultProps = defaultProps;
|