@deck.gl/carto 8.6.0 → 8.6.4
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 +85 -20
- package/dist/es5/api/index.js +13 -7
- package/dist/es5/api/index.js.map +1 -1
- package/dist/es5/api/maps-api-common.js +11 -6
- package/dist/es5/api/maps-api-common.js.map +1 -1
- package/dist/es5/api/maps-client.js +98 -151
- package/dist/es5/api/maps-client.js.map +1 -1
- package/dist/es5/api/maps-v3-client.js +206 -253
- package/dist/es5/api/maps-v3-client.js.map +1 -1
- package/dist/es5/basemap.js +1 -1
- package/dist/es5/basemap.js.map +1 -1
- package/dist/es5/config.js +25 -25
- package/dist/es5/config.js.map +1 -1
- package/dist/es5/index.js +21 -15
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/layers/carto-bqtiler-layer.js +6 -39
- package/dist/es5/layers/carto-bqtiler-layer.js.map +1 -1
- package/dist/es5/layers/carto-layer.js +132 -211
- package/dist/es5/layers/carto-layer.js.map +1 -1
- package/dist/es5/layers/carto-sql-layer.js +6 -39
- package/dist/es5/layers/carto-sql-layer.js.map +1 -1
- package/dist/es5/style/color-bins-style.js +10 -11
- package/dist/es5/style/color-bins-style.js.map +1 -1
- package/dist/es5/style/color-categories-style.js +13 -38
- package/dist/es5/style/color-categories-style.js.map +1 -1
- package/dist/es5/style/color-continuous-style.js +10 -11
- package/dist/es5/style/color-continuous-style.js.map +1 -1
- package/dist/es5/style/palette.js +11 -19
- package/dist/es5/style/palette.js.map +1 -1
- package/dist/es5/style/utils.js +6 -13
- package/dist/es5/style/utils.js.map +1 -1
- package/dist/esm/api/index.js +1 -1
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/maps-api-common.js +4 -0
- package/dist/esm/api/maps-api-common.js.map +1 -1
- package/dist/esm/api/maps-client.js +11 -6
- package/dist/esm/api/maps-client.js.map +1 -1
- package/dist/esm/api/maps-v3-client.js +70 -16
- package/dist/esm/api/maps-v3-client.js.map +1 -1
- package/dist/esm/config.js +4 -4
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +2 -2
- package/src/api/index.js +1 -1
- package/src/api/maps-api-common.js +5 -0
- package/src/api/maps-client.js +16 -3
- package/src/api/maps-v3-client.js +52 -11
- package/src/config.js +4 -4
- package/src/index.js +1 -0
package/src/api/maps-client.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Maps API Client for Maps API v1 and Maps API v2
|
|
3
3
|
*/
|
|
4
|
-
import {getDefaultCredentials} from '../config';
|
|
4
|
+
import {defaultClassicCredentials, getDefaultCredentials} from '../config';
|
|
5
5
|
import {
|
|
6
6
|
API_VERSIONS,
|
|
7
|
+
DEFAULT_MAPS_URL_FORMAT,
|
|
7
8
|
DEFAULT_REGION_COMPONENT_IN_URL,
|
|
8
9
|
DEFAULT_USER_COMPONENT_IN_URL,
|
|
9
10
|
encodeParameter,
|
|
@@ -22,8 +23,20 @@ const TILE_EXTENT = 4096;
|
|
|
22
23
|
* Obtain a TileJson from Maps API v1 and v2
|
|
23
24
|
*/
|
|
24
25
|
export async function getDataV2({type, source, credentials}) {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
26
|
+
const defaultCredentials = getDefaultCredentials();
|
|
27
|
+
const apiVersion = (credentials && credentials.apiVersion) || defaultCredentials.apiVersion;
|
|
28
|
+
// Only pick up default credentials if they have been defined for
|
|
29
|
+
// correct API version
|
|
30
|
+
const localCreds = {
|
|
31
|
+
...defaultClassicCredentials,
|
|
32
|
+
...(defaultCredentials.apiVersion === apiVersion && defaultCredentials),
|
|
33
|
+
...credentials
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (!localCreds.mapsUrl) {
|
|
37
|
+
localCreds.mapsUrl = DEFAULT_MAPS_URL_FORMAT[apiVersion];
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
let url;
|
|
28
41
|
|
|
29
42
|
const connection = type === 'tileset' ? CONNECTIONS.BIGQUERY : CONNECTIONS.CARTO;
|
|
@@ -68,9 +68,11 @@ function dealWithError({response, error}) {
|
|
|
68
68
|
/**
|
|
69
69
|
* Build a URL with all required parameters
|
|
70
70
|
*/
|
|
71
|
-
function getParameters({type, source, geoColumn, columns}) {
|
|
72
|
-
const
|
|
73
|
-
|
|
71
|
+
function getParameters({type, source, geoColumn, columns, schema}) {
|
|
72
|
+
const parameters = [encodeParameter('client', 'deck-gl-carto')];
|
|
73
|
+
if (schema) {
|
|
74
|
+
parameters.push(encodeParameter('schema', true));
|
|
75
|
+
}
|
|
74
76
|
|
|
75
77
|
const sourceName = type === MAP_TYPES.QUERY ? 'q' : 'name';
|
|
76
78
|
parameters.push(encodeParameter(sourceName, source));
|
|
@@ -93,10 +95,11 @@ export async function mapInstantiation({
|
|
|
93
95
|
connection,
|
|
94
96
|
credentials,
|
|
95
97
|
geoColumn,
|
|
96
|
-
columns
|
|
98
|
+
columns,
|
|
99
|
+
schema
|
|
97
100
|
}) {
|
|
98
101
|
const baseUrl = `${credentials.mapsUrl}/${connection}/${type}`;
|
|
99
|
-
const url = `${baseUrl}?${getParameters({type, source, geoColumn, columns})}`;
|
|
102
|
+
const url = `${baseUrl}?${getParameters({type, source, geoColumn, columns, schema})}`;
|
|
100
103
|
const {accessToken} = credentials;
|
|
101
104
|
|
|
102
105
|
const format = 'json';
|
|
@@ -123,9 +126,7 @@ function getUrlFromMetadata(metadata, format) {
|
|
|
123
126
|
return null;
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
|
|
127
|
-
const localCreds = {...getDefaultCredentials(), ...credentials};
|
|
128
|
-
|
|
129
|
+
function checkGetLayerDataParameters({type, source, connection, localCreds}) {
|
|
129
130
|
log.assert(connection, 'Must define connection');
|
|
130
131
|
log.assert(type, 'Must define a type');
|
|
131
132
|
log.assert(source, 'Must define a source');
|
|
@@ -133,7 +134,26 @@ export async function getData({type, source, connection, credentials, geoColumn,
|
|
|
133
134
|
log.assert(localCreds.apiVersion === API_VERSIONS.V3, 'Method only available for v3');
|
|
134
135
|
log.assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
|
|
135
136
|
log.assert(localCreds.accessToken, 'Must define an accessToken');
|
|
136
|
-
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function fetchLayerData({
|
|
140
|
+
type,
|
|
141
|
+
source,
|
|
142
|
+
connection,
|
|
143
|
+
credentials,
|
|
144
|
+
geoColumn,
|
|
145
|
+
columns,
|
|
146
|
+
format,
|
|
147
|
+
schema
|
|
148
|
+
}) {
|
|
149
|
+
const defaultCredentials = getDefaultCredentials();
|
|
150
|
+
// Only pick up default credentials if they have been defined for
|
|
151
|
+
// correct API version
|
|
152
|
+
const localCreds = {
|
|
153
|
+
...(defaultCredentials.apiVersion === API_VERSIONS.V3 && defaultCredentials),
|
|
154
|
+
...credentials
|
|
155
|
+
};
|
|
156
|
+
checkGetLayerDataParameters({type, source, connection, localCreds});
|
|
137
157
|
|
|
138
158
|
if (!localCreds.mapsUrl) {
|
|
139
159
|
localCreds.mapsUrl = buildMapsUrlFromBase(localCreds.apiBaseUrl);
|
|
@@ -145,7 +165,8 @@ export async function getData({type, source, connection, credentials, geoColumn,
|
|
|
145
165
|
connection,
|
|
146
166
|
credentials: localCreds,
|
|
147
167
|
geoColumn,
|
|
148
|
-
columns
|
|
168
|
+
columns,
|
|
169
|
+
schema
|
|
149
170
|
});
|
|
150
171
|
let url;
|
|
151
172
|
let mapFormat;
|
|
@@ -168,5 +189,25 @@ export async function getData({type, source, connection, credentials, geoColumn,
|
|
|
168
189
|
|
|
169
190
|
const {accessToken} = localCreds;
|
|
170
191
|
|
|
171
|
-
|
|
192
|
+
const data = await request({url, format: mapFormat, accessToken});
|
|
193
|
+
const result = {data, format: mapFormat};
|
|
194
|
+
if (schema) {
|
|
195
|
+
result.schema = metadata.schema;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function getData({type, source, connection, credentials, geoColumn, columns, format}) {
|
|
202
|
+
const layerData = await fetchLayerData({
|
|
203
|
+
type,
|
|
204
|
+
source,
|
|
205
|
+
connection,
|
|
206
|
+
credentials,
|
|
207
|
+
geoColumn,
|
|
208
|
+
columns,
|
|
209
|
+
format,
|
|
210
|
+
schema: false
|
|
211
|
+
});
|
|
212
|
+
return layerData.data;
|
|
172
213
|
}
|
package/src/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {API_VERSIONS} from './api/maps-api-common';
|
|
1
|
+
import {API_VERSIONS, DEFAULT_MAPS_URL_FORMAT} from './api/maps-api-common';
|
|
2
2
|
|
|
3
|
-
const defaultClassicCredentials = {
|
|
3
|
+
export const defaultClassicCredentials = {
|
|
4
4
|
username: 'public',
|
|
5
5
|
apiKey: 'default_public',
|
|
6
6
|
region: 'us',
|
|
@@ -22,7 +22,7 @@ export function setDefaultCredentials(opts) {
|
|
|
22
22
|
|
|
23
23
|
switch (apiVersion) {
|
|
24
24
|
case API_VERSIONS.V1:
|
|
25
|
-
opts.mapsUrl = opts.mapsUrl ||
|
|
25
|
+
opts.mapsUrl = opts.mapsUrl || DEFAULT_MAPS_URL_FORMAT[apiVersion];
|
|
26
26
|
credentials = {
|
|
27
27
|
apiVersion,
|
|
28
28
|
...defaultClassicCredentials,
|
|
@@ -31,7 +31,7 @@ export function setDefaultCredentials(opts) {
|
|
|
31
31
|
break;
|
|
32
32
|
|
|
33
33
|
case API_VERSIONS.V2:
|
|
34
|
-
opts.mapsUrl = opts.mapsUrl ||
|
|
34
|
+
opts.mapsUrl = opts.mapsUrl || DEFAULT_MAPS_URL_FORMAT[apiVersion];
|
|
35
35
|
credentials = {
|
|
36
36
|
apiVersion,
|
|
37
37
|
...defaultClassicCredentials,
|