@deck.gl/carto 8.7.0-alpha.1 → 8.7.0-alpha.8

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.
Files changed (62) hide show
  1. package/dist/dist.dev.js +1521 -1700
  2. package/dist/es5/api/layer-map.js +4 -3
  3. package/dist/es5/api/layer-map.js.map +1 -1
  4. package/dist/es5/api/maps-client.js +2 -2
  5. package/dist/es5/api/maps-client.js.map +1 -1
  6. package/dist/es5/api/maps-v3-client.js +34 -27
  7. package/dist/es5/api/maps-v3-client.js.map +1 -1
  8. package/dist/es5/api/parseMap.js +9 -13
  9. package/dist/es5/api/parseMap.js.map +1 -1
  10. package/dist/es5/config.js +15 -24
  11. package/dist/es5/config.js.map +1 -1
  12. package/dist/es5/index.js +0 -16
  13. package/dist/es5/index.js.map +1 -1
  14. package/dist/es5/layers/carto-layer.js +50 -51
  15. package/dist/es5/layers/carto-layer.js.map +1 -1
  16. package/dist/es5/style/color-bins-style.js +6 -2
  17. package/dist/es5/style/color-bins-style.js.map +1 -1
  18. package/dist/es5/style/color-categories-style.js +7 -3
  19. package/dist/es5/style/color-categories-style.js.map +1 -1
  20. package/dist/es5/style/color-continuous-style.js +6 -2
  21. package/dist/es5/style/color-continuous-style.js.map +1 -1
  22. package/dist/es5/style/palette.js +6 -2
  23. package/dist/es5/style/palette.js.map +1 -1
  24. package/dist/esm/api/layer-map.js +3 -2
  25. package/dist/esm/api/layer-map.js.map +1 -1
  26. package/dist/esm/api/maps-client.js +1 -1
  27. package/dist/esm/api/maps-client.js.map +1 -1
  28. package/dist/esm/api/maps-v3-client.js +23 -13
  29. package/dist/esm/api/maps-v3-client.js.map +1 -1
  30. package/dist/esm/api/parseMap.js +3 -10
  31. package/dist/esm/api/parseMap.js.map +1 -1
  32. package/dist/esm/config.js +11 -26
  33. package/dist/esm/config.js.map +1 -1
  34. package/dist/esm/index.js +0 -2
  35. package/dist/esm/index.js.map +1 -1
  36. package/dist/esm/layers/carto-layer.js +28 -28
  37. package/dist/esm/layers/carto-layer.js.map +1 -1
  38. package/dist/esm/style/color-bins-style.js +1 -1
  39. package/dist/esm/style/color-bins-style.js.map +1 -1
  40. package/dist/esm/style/color-continuous-style.js +1 -1
  41. package/dist/esm/style/color-continuous-style.js.map +1 -1
  42. package/dist.min.js +4 -4
  43. package/package.json +7 -7
  44. package/src/api/layer-map.js +3 -2
  45. package/src/api/maps-client.js +3 -7
  46. package/src/api/maps-v3-client.js +24 -13
  47. package/src/api/parseMap.js +17 -26
  48. package/src/config.js +8 -39
  49. package/src/index.js +0 -2
  50. package/src/layers/carto-layer.js +17 -23
  51. package/src/style/color-bins-style.js +2 -4
  52. package/src/style/color-continuous-style.js +2 -4
  53. package/dist/es5/layers/carto-bqtiler-layer.js +0 -65
  54. package/dist/es5/layers/carto-bqtiler-layer.js.map +0 -1
  55. package/dist/es5/layers/carto-sql-layer.js +0 -66
  56. package/dist/es5/layers/carto-sql-layer.js.map +0 -1
  57. package/dist/esm/layers/carto-bqtiler-layer.js +0 -16
  58. package/dist/esm/layers/carto-bqtiler-layer.js.map +0 -1
  59. package/dist/esm/layers/carto-sql-layer.js +0 -17
  60. package/dist/esm/layers/carto-sql-layer.js.map +0 -1
  61. package/src/layers/carto-bqtiler-layer.js +0 -21
  62. package/src/layers/carto-sql-layer.js +0 -22
@@ -8,59 +8,50 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.setDefaultCredentials = setDefaultCredentials;
9
9
  exports.getDefaultCredentials = getDefaultCredentials;
10
10
  exports.buildMapsUrlFromBase = buildMapsUrlFromBase;
11
- exports.defaultClassicCredentials = void 0;
11
+ exports.defaultCloudNativeCredentials = exports.defaultClassicCredentials = void 0;
12
12
 
13
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
 
15
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
16
+
15
17
  var _mapsApiCommon = require("./api/maps-api-common");
16
18
 
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
19
+ var _excluded = ["apiVersion"];
20
+
21
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
18
22
 
19
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
24
 
21
25
  var defaultClassicCredentials = {
22
- username: 'public',
23
26
  apiKey: 'default_public',
24
27
  region: 'us',
25
- mapsUrl: null
28
+ username: 'public'
26
29
  };
27
30
  exports.defaultClassicCredentials = defaultClassicCredentials;
28
31
  var defaultCloudNativeCredentials = {
29
- accessToken: null,
30
- apiBaseUrl: null,
31
- mapsUrl: null
32
+ apiBaseUrl: 'https://gcp-us-east1.api.carto.com'
32
33
  };
34
+ exports.defaultCloudNativeCredentials = defaultCloudNativeCredentials;
33
35
  var credentials = {};
34
36
  setDefaultCredentials({});
35
37
 
36
- function setDefaultCredentials(opts) {
37
- var apiVersion = opts.apiVersion || _mapsApiCommon.API_VERSIONS.V2;
38
+ function setDefaultCredentials(_ref) {
39
+ var apiVersion = _ref.apiVersion,
40
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
41
+ apiVersion = apiVersion || _mapsApiCommon.API_VERSIONS.V3;
38
42
 
39
43
  switch (apiVersion) {
40
44
  case _mapsApiCommon.API_VERSIONS.V1:
41
- opts.mapsUrl = opts.mapsUrl || _mapsApiCommon.DEFAULT_MAPS_URL_FORMAT[apiVersion];
42
- credentials = _objectSpread(_objectSpread({
43
- apiVersion: apiVersion
44
- }, defaultClassicCredentials), opts);
45
- break;
46
-
47
45
  case _mapsApiCommon.API_VERSIONS.V2:
48
- opts.mapsUrl = opts.mapsUrl || _mapsApiCommon.DEFAULT_MAPS_URL_FORMAT[apiVersion];
49
46
  credentials = _objectSpread(_objectSpread({
50
47
  apiVersion: apiVersion
51
- }, defaultClassicCredentials), opts);
48
+ }, defaultClassicCredentials), rest);
52
49
  break;
53
50
 
54
51
  case _mapsApiCommon.API_VERSIONS.V3:
55
- if (!opts.apiBaseUrl) {
56
- throw new Error("API version ".concat(_mapsApiCommon.API_VERSIONS.V3, " requires to define apiBaseUrl at credentials. Go to https://app.carto.com to get your apiBaseUrl."));
57
- }
58
-
59
- var apiBaseUrl = opts.apiBaseUrl || defaultCloudNativeCredentials.apiBaseUrl;
60
- opts.mapsUrl = opts.mapsUrl || buildMapsUrlFromBase(apiBaseUrl);
61
52
  credentials = _objectSpread(_objectSpread({
62
53
  apiVersion: apiVersion
63
- }, defaultCloudNativeCredentials), opts);
54
+ }, defaultCloudNativeCredentials), rest);
64
55
  break;
65
56
 
66
57
  default:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config.js"],"names":["defaultClassicCredentials","username","apiKey","region","mapsUrl","defaultCloudNativeCredentials","accessToken","apiBaseUrl","credentials","setDefaultCredentials","opts","apiVersion","API_VERSIONS","V2","V1","DEFAULT_MAPS_URL_FORMAT","V3","Error","buildMapsUrlFromBase","getDefaultCredentials","suffix","endsWith","substring"],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;AAEO,IAAMA,yBAAyB,GAAG;AACvCC,EAAAA,QAAQ,EAAE,QAD6B;AAEvCC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IAHM,CAAX;AAKA;;AACF;AACE,YAAM,IAAIO,KAAJ,+BAAiCN,UAAjC,8BAAN;AArCJ;AAuCD;;AAEM,SAASQ,qBAAT,GAAiC;AACtC,SAAOX,WAAP;AACD;;AAEM,SAASU,oBAAT,CAA8BX,UAA9B,EAA0C;AAC/C,MAAIa,MAAM,GAAG,UAAb;;AACA,MAAIb,UAAU,CAACc,QAAX,CAAoB,GAApB,CAAJ,EAA8B;AAC5BD,IAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,CAAjB,CAAT;AACD;;AAED,mBAAUf,UAAV,SAAuBa,MAAvB;AACD","sourcesContent":["import {API_VERSIONS, DEFAULT_MAPS_URL_FORMAT} from './api/maps-api-common';\n\nexport const defaultClassicCredentials = {\n username: 'public',\n apiKey: 'default_public',\n region: 'us',\n mapsUrl: null\n};\n\nconst defaultCloudNativeCredentials = {\n accessToken: null,\n apiBaseUrl: null,\n mapsUrl: null\n};\n\nlet credentials = {};\n\nsetDefaultCredentials({});\n\nexport function setDefaultCredentials(opts) {\n const apiVersion = opts.apiVersion || API_VERSIONS.V2;\n\n switch (apiVersion) {\n case API_VERSIONS.V1:\n opts.mapsUrl = opts.mapsUrl || DEFAULT_MAPS_URL_FORMAT[apiVersion];\n credentials = {\n apiVersion,\n ...defaultClassicCredentials,\n ...opts\n };\n break;\n\n case API_VERSIONS.V2:\n opts.mapsUrl = opts.mapsUrl || DEFAULT_MAPS_URL_FORMAT[apiVersion];\n credentials = {\n apiVersion,\n ...defaultClassicCredentials,\n ...opts\n };\n\n break;\n case API_VERSIONS.V3:\n if (!opts.apiBaseUrl) {\n throw new Error(\n `API version ${\n API_VERSIONS.V3\n } requires to define apiBaseUrl at credentials. Go to https://app.carto.com to get your apiBaseUrl.`\n );\n }\n\n const apiBaseUrl = opts.apiBaseUrl || defaultCloudNativeCredentials.apiBaseUrl;\n opts.mapsUrl = opts.mapsUrl || buildMapsUrlFromBase(apiBaseUrl);\n credentials = {\n apiVersion,\n ...defaultCloudNativeCredentials,\n ...opts\n };\n break;\n default:\n throw new Error(`Invalid API version ${apiVersion}. Use API_VERSIONS enum.`);\n }\n}\n\nexport function getDefaultCredentials() {\n return credentials;\n}\n\nexport function buildMapsUrlFromBase(apiBaseUrl) {\n let suffix = '/v3/maps';\n if (apiBaseUrl.endsWith('/')) {\n suffix = suffix.substring(1);\n }\n\n return `${apiBaseUrl}${suffix}`;\n}\n"],"file":"config.js"}
1
+ {"version":3,"sources":["../../src/config.js"],"names":["defaultClassicCredentials","apiKey","region","username","defaultCloudNativeCredentials","apiBaseUrl","credentials","setDefaultCredentials","apiVersion","rest","API_VERSIONS","V3","V1","V2","Error","getDefaultCredentials","buildMapsUrlFromBase","suffix","endsWith","substring"],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;AAEO,IAAMA,yBAAyB,GAAG;AACvCC,EAAAA,MAAM,EAAE,gBAD+B;AAEvCC,EAAAA,MAAM,EAAE,IAF+B;AAGvCC,EAAAA,QAAQ,EAAE;AAH6B,CAAlC;;AAMA,IAAMC,6BAA6B,GAAG;AAC3CC,EAAAA,UAAU,EAAE;AAD+B,CAAtC;;AAIP,IAAIC,WAAW,GAAG,EAAlB;AAEAC,qBAAqB,CAAC,EAAD,CAArB;;AAEO,SAASA,qBAAT,OAAsD;AAAA,MAAtBC,UAAsB,QAAtBA,UAAsB;AAAA,MAAPC,IAAO;AAC3DD,EAAAA,UAAU,GAAGA,UAAU,IAAIE,4BAAaC,EAAxC;;AAEA,UAAQH,UAAR;AACE,SAAKE,4BAAaE,EAAlB;AACA,SAAKF,4BAAaG,EAAlB;AACEP,MAAAA,WAAW;AAAIE,QAAAA,UAAU,EAAVA;AAAJ,SAAmBR,yBAAnB,GAAiDS,IAAjD,CAAX;AACA;;AACF,SAAKC,4BAAaC,EAAlB;AACEL,MAAAA,WAAW;AAAIE,QAAAA,UAAU,EAAVA;AAAJ,SAAmBJ,6BAAnB,GAAqDK,IAArD,CAAX;AACA;;AACF;AACE,YAAM,IAAIK,KAAJ,+BAAiCN,UAAjC,8BAAN;AATJ;AAWD;;AAEM,SAASO,qBAAT,GAAiC;AACtC,SAAOT,WAAP;AACD;;AAEM,SAASU,oBAAT,CAA8BX,UAA9B,EAA0C;AAC/C,MAAIY,MAAM,GAAG,UAAb;;AACA,MAAIZ,UAAU,CAACa,QAAX,CAAoB,GAApB,CAAJ,EAA8B;AAC5BD,IAAAA,MAAM,GAAGA,MAAM,CAACE,SAAP,CAAiB,CAAjB,CAAT;AACD;;AAED,mBAAUd,UAAV,SAAuBY,MAAvB;AACD","sourcesContent":["import {API_VERSIONS} from './api/maps-api-common';\n\nexport const defaultClassicCredentials = {\n apiKey: 'default_public',\n region: 'us',\n username: 'public'\n};\n\nexport const defaultCloudNativeCredentials = {\n apiBaseUrl: 'https://gcp-us-east1.api.carto.com'\n};\n\nlet credentials = {};\n\nsetDefaultCredentials({});\n\nexport function setDefaultCredentials({apiVersion, ...rest}) {\n apiVersion = apiVersion || API_VERSIONS.V3;\n\n switch (apiVersion) {\n case API_VERSIONS.V1:\n case API_VERSIONS.V2:\n credentials = {apiVersion, ...defaultClassicCredentials, ...rest};\n break;\n case API_VERSIONS.V3:\n credentials = {apiVersion, ...defaultCloudNativeCredentials, ...rest};\n break;\n default:\n throw new Error(`Invalid API version ${apiVersion}. Use API_VERSIONS enum.`);\n }\n}\n\nexport function getDefaultCredentials() {\n return credentials;\n}\n\nexport function buildMapsUrlFromBase(apiBaseUrl) {\n let suffix = '/v3/maps';\n if (apiBaseUrl.endsWith('/')) {\n suffix = suffix.substring(1);\n }\n\n return `${apiBaseUrl}${suffix}`;\n}\n"],"file":"config.js"}
package/dist/es5/index.js CHANGED
@@ -17,18 +17,6 @@ Object.defineProperty(exports, "setDefaultCredentials", {
17
17
  return _config.setDefaultCredentials;
18
18
  }
19
19
  });
20
- Object.defineProperty(exports, "CartoSQLLayer", {
21
- enumerable: true,
22
- get: function get() {
23
- return _cartoSqlLayer.default;
24
- }
25
- });
26
- Object.defineProperty(exports, "CartoBQTilerLayer", {
27
- enumerable: true,
28
- get: function get() {
29
- return _cartoBqtilerLayer.default;
30
- }
31
- });
32
20
  Object.defineProperty(exports, "CartoLayer", {
33
21
  enumerable: true,
34
22
  get: function get() {
@@ -110,10 +98,6 @@ Object.defineProperty(exports, "_mapInstantiation", {
110
98
 
111
99
  var _config = require("./config.js");
112
100
 
113
- var _cartoSqlLayer = _interopRequireDefault(require("./layers/carto-sql-layer"));
114
-
115
- var _cartoBqtilerLayer = _interopRequireDefault(require("./layers/carto-bqtiler-layer"));
116
-
117
101
  var _cartoLayer = _interopRequireDefault(require("./layers/carto-layer"));
118
102
 
119
103
  var _basemap = _interopRequireDefault(require("./basemap"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export {getDefaultCredentials, setDefaultCredentials} from './config.js';\nexport {default as CartoSQLLayer} from './layers/carto-sql-layer';\nexport {default as CartoBQTilerLayer} from './layers/carto-bqtiler-layer';\nexport {default as CartoLayer} from './layers/carto-layer';\nexport {default as BASEMAP} from './basemap';\nexport {default as colorBins} from './style/color-bins-style';\nexport {default as colorCategories} from './style/color-categories-style';\nexport {default as colorContinuous} from './style/color-continuous-style';\nexport {\n FORMATS,\n MAP_TYPES,\n API_VERSIONS,\n fetchLayerData,\n fetchMap,\n getDataV2 as _getDataV2,\n getData,\n mapInstantiation as _mapInstantiation\n} from './api';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export {getDefaultCredentials, setDefaultCredentials} from './config.js';\nexport {default as CartoLayer} from './layers/carto-layer';\nexport {default as BASEMAP} from './basemap';\nexport {default as colorBins} from './style/color-bins-style';\nexport {default as colorCategories} from './style/color-categories-style';\nexport {default as colorContinuous} from './style/color-continuous-style';\nexport {\n FORMATS,\n MAP_TYPES,\n API_VERSIONS,\n fetchLayerData,\n fetchMap,\n getDataV2 as _getDataV2,\n getData,\n mapInstantiation as _mapInstantiation\n} from './api';\n"],"file":"index.js"}
@@ -9,6 +9,8 @@ exports.default = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
12
14
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
15
 
14
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -37,13 +39,15 @@ var _mapsApiCommon = require("../api/maps-api-common");
37
39
 
38
40
  var _config = require("../config");
39
41
 
40
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
42
+ var _excluded = ["type", "data", "credentials"];
43
+
44
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
41
45
 
42
46
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
43
47
 
44
48
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
45
49
 
46
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
50
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
47
51
 
48
52
  var defaultProps = {
49
53
  data: null,
@@ -59,8 +63,10 @@ var defaultProps = {
59
63
  compare: false,
60
64
  optional: true
61
65
  },
66
+ uniqueIdProperty: 'cartodb_id',
62
67
  credentials: null,
63
68
  connection: null,
69
+ format: null,
64
70
  geoColumn: null,
65
71
  columns: {
66
72
  type: 'array',
@@ -86,6 +92,11 @@ var CartoLayer = function (_CompositeLayer) {
86
92
  apiVersion: null
87
93
  };
88
94
  }
95
+ }, {
96
+ key: "isLoaded",
97
+ get: function get() {
98
+ return this.getSubLayers().length > 0 && (0, _get2.default)((0, _getPrototypeOf2.default)(CartoLayer.prototype), "isLoaded", this);
99
+ }
89
100
  }, {
90
101
  key: "_checkProps",
91
102
  value: function _checkProps(props) {
@@ -149,89 +160,78 @@ var CartoLayer = function (_CompositeLayer) {
149
160
  key: "_updateData",
150
161
  value: function () {
151
162
  var _updateData2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
152
- var _this$props, type, source, connection, credentials, geoColumn, columns, localConfig, apiVersion, data;
163
+ var _this$props, type, source, credentials, rest, localConfig, apiVersion, result;
153
164
 
154
165
  return _regenerator.default.wrap(function _callee$(_context) {
155
166
  while (1) {
156
167
  switch (_context.prev = _context.next) {
157
168
  case 0:
158
169
  _context.prev = 0;
159
- _this$props = this.props, type = _this$props.type, source = _this$props.data, connection = _this$props.connection, credentials = _this$props.credentials, geoColumn = _this$props.geoColumn, columns = _this$props.columns;
170
+ _this$props = this.props, type = _this$props.type, source = _this$props.data, credentials = _this$props.credentials, rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
160
171
  localConfig = _objectSpread(_objectSpread({}, (0, _config.getDefaultCredentials)()), credentials);
161
172
  apiVersion = localConfig.apiVersion;
162
173
 
163
- if (!(apiVersion === _api.API_VERSIONS.V3)) {
164
- _context.next = 10;
174
+ if (!(apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2)) {
175
+ _context.next = 11;
165
176
  break;
166
177
  }
167
178
 
168
179
  _context.next = 7;
169
- return (0, _api.getData)({
180
+ return (0, _api.getDataV2)({
170
181
  type: type,
171
182
  source: source,
172
- connection: connection,
173
- credentials: credentials,
174
- geoColumn: geoColumn,
175
- columns: columns
183
+ credentials: credentials
176
184
  });
177
185
 
178
186
  case 7:
179
- data = _context.sent;
180
- _context.next = 17;
187
+ _context.t0 = _context.sent;
188
+ result = {
189
+ data: _context.t0
190
+ };
191
+ _context.next = 14;
181
192
  break;
182
193
 
183
- case 10:
184
- if (!(apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2)) {
185
- _context.next = 16;
186
- break;
187
- }
188
-
194
+ case 11:
189
195
  _context.next = 13;
190
- return (0, _api.getDataV2)({
196
+ return (0, _api.fetchLayerData)(_objectSpread({
191
197
  type: type,
192
198
  source: source,
193
199
  credentials: credentials
194
- });
200
+ }, rest));
195
201
 
196
202
  case 13:
197
- data = _context.sent;
198
- _context.next = 17;
199
- break;
200
-
201
- case 16:
202
- _core.log.assert("Unknow apiVersion ".concat(apiVersion, ". Use API_VERSIONS enum."));
203
+ result = _context.sent;
203
204
 
204
- case 17:
205
- this.setState({
206
- data: data,
205
+ case 14:
206
+ this.setState(_objectSpread(_objectSpread({}, result), {}, {
207
207
  apiVersion: apiVersion
208
- });
209
- this.props.onDataLoad(data);
210
- _context.next = 28;
208
+ }));
209
+ this.props.onDataLoad(result.data);
210
+ _context.next = 25;
211
211
  break;
212
212
 
213
- case 21:
214
- _context.prev = 21;
215
- _context.t0 = _context["catch"](0);
213
+ case 18:
214
+ _context.prev = 18;
215
+ _context.t1 = _context["catch"](0);
216
216
 
217
217
  if (!this.props.onDataError) {
218
- _context.next = 27;
218
+ _context.next = 24;
219
219
  break;
220
220
  }
221
221
 
222
- this.props.onDataError(_context.t0);
223
- _context.next = 28;
222
+ this.props.onDataError(_context.t1);
223
+ _context.next = 25;
224
224
  break;
225
225
 
226
- case 27:
227
- throw _context.t0;
226
+ case 24:
227
+ throw _context.t1;
228
228
 
229
- case 28:
229
+ case 25:
230
230
  case "end":
231
231
  return _context.stop();
232
232
  }
233
233
  }
234
- }, _callee, this, [[0, 21]]);
234
+ }, _callee, this, [[0, 18]]);
235
235
  }));
236
236
 
237
237
  function _updateData() {
@@ -245,19 +245,23 @@ var CartoLayer = function (_CompositeLayer) {
245
245
  value: function renderLayers() {
246
246
  var _this$state = this.state,
247
247
  data = _this$state.data,
248
+ format = _this$state.format,
248
249
  apiVersion = _this$state.apiVersion;
249
- var type = this.props.type;
250
250
  if (!data) return null;
251
251
  var updateTriggers = this.props.updateTriggers;
252
252
  var layer;
253
253
 
254
- if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2 || type === _mapsApiCommon.MAP_TYPES.TILESET) {
254
+ if (apiVersion === _api.API_VERSIONS.V1 || apiVersion === _api.API_VERSIONS.V2 || format === _mapsApiCommon.FORMATS.TILEJSON) {
255
255
  layer = _geoLayers.MVTLayer;
256
256
  } else {
257
257
  layer = _layers.GeoJsonLayer;
258
258
  }
259
259
 
260
- var props = _objectSpread({}, this.props);
260
+ var uniqueIdProperty = defaultProps.uniqueIdProperty;
261
+
262
+ var props = _objectSpread({
263
+ uniqueIdProperty: uniqueIdProperty
264
+ }, this.props);
261
265
 
262
266
  delete props.data;
263
267
  return new layer(props, this.getSubLayerProps({
@@ -266,11 +270,6 @@ var CartoLayer = function (_CompositeLayer) {
266
270
  updateTriggers: updateTriggers
267
271
  }));
268
272
  }
269
- }, {
270
- key: "isLoaded",
271
- get: function get() {
272
- return this.getSubLayers().length > 0 && (0, _get2.default)((0, _getPrototypeOf2.default)(CartoLayer.prototype), "isLoaded", this);
273
- }
274
273
  }]);
275
274
  return CartoLayer;
276
275
  }(_core.CompositeLayer);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/layers/carto-layer.js"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","credentials","connection","geoColumn","columns","CartoLayer","state","apiVersion","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","TABLE","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","localConfig","updateTriggers","layer","MVTLayer","GeoJsonLayer","getSubLayerProps","id","layerName","getSubLayers","length","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE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A;AAAP,iBAAd;AACA,qBAAKC,KAAL,CAAWZ,UAAX,CAAsBF,IAAtB;;;;;;;;qBAEI,KAAKc,KAAL,CAAWT,W;;;;;AACb,qBAAKS,KAAL,CAAWT,WAAX;;;;;;;;;;;;;;;;;;;;;;;mCAOS;AAAA,wBACc,KAAKO,KADnB;AAAA,UACNZ,IADM,eACNA,IADM;AAAA,UACAa,UADA,eACAA,UADA;AAAA,UAENZ,IAFM,GAEE,KAAKa,KAFP,CAENb,IAFM;AAIb,UAAI,CAACD,IAAL,EAAW,OAAO,IAAP;AAJE,UAMN0C,cANM,GAMY,KAAK5B,KANjB,CAMN4B,cANM;AAQb,UAAIC,KAAJ;;AAEA,UACE9B,UAAU,KAAKO,kBAAaE,EAA5B,IACAT,UAAU,KAAKO,kBAAaG,EAD5B,IAEAtB,IAAI,KAAKuB,yBAAUE,OAHrB,EAIE;AACAiB,QAAAA,KAAK,GAAGC,mBAAR;AACD,OAND,MAMO;AACLD,QAAAA,KAAK,GAAGE,oBAAR;AACD;;AAED,UAAM/B,KAAK,qBAAO,KAAKA,KAAZ,CAAX;;AACA,aAAOA,KAAK,CAACd,IAAb;AAGA,aAAO,IAAI2C,KAAJ,CACL7B,KADK,EAEL,KAAKgC,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWJ,KAAK,CAACK,SAAjB,CADkB;AAEpBhD,QAAAA,IAAI,EAAJA,IAFoB;AAGpB0C,QAAAA,cAAc,EAAdA;AAHoB,OAAtB,CAFK,CAAP;AAQD;;;wBAxHc;AACb,aAAO,KAAKO,YAAL,GAAoBC,MAApB,GAA6B,CAA7B,6FAAP;AACD;;;EAVqCC,oB;;;AAmIxCxC,UAAU,CAACqC,SAAX,GAAuB,YAAvB;AACArC,UAAU,CAACZ,YAAX,GAA0BA,YAA1B","sourcesContent":["import {CompositeLayer, log} from '@deck.gl/core';\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {getData, getDataV2, API_VERSIONS} from '../api';\nimport {MAP_TYPES} from '../api/maps-api-common';\nimport {getDefaultCredentials} from '../config';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null}\n};\n\nexport default class CartoLayer extends CompositeLayer {\n initializeState() {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded() {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props) {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (type !== MAP_TYPES.TABLE) {\n log.assert(!geoColumn, `geoColumn prop is only supported for type ${MAP_TYPES.TABLE}`);\n log.assert(!columns, `columns prop is only supported for type ${MAP_TYPES.TABLE}`);\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n props.type !== oldProps.type ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n this._updateData();\n }\n }\n\n async _updateData() {\n try {\n const {type, data: source, connection, credentials, geoColumn, columns} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let data;\n\n if (apiVersion === API_VERSIONS.V3) {\n data = await getData({\n type,\n source,\n connection,\n credentials,\n geoColumn,\n columns\n });\n } else if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n data = await getDataV2({type, source, credentials});\n } else {\n log.assert(`Unknow apiVersion ${apiVersion}. Use API_VERSIONS enum.`);\n }\n\n this.setState({data, apiVersion});\n this.props.onDataLoad(data);\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err);\n } else {\n throw err;\n }\n }\n }\n\n renderLayers() {\n const {data, apiVersion} = this.state;\n const {type} = this.props;\n\n if (!data) return null;\n\n const {updateTriggers} = this.props;\n\n let layer;\n\n if (\n apiVersion === API_VERSIONS.V1 ||\n apiVersion === API_VERSIONS.V2 ||\n type === MAP_TYPES.TILESET\n ) {\n layer = MVTLayer;\n } else {\n layer = GeoJsonLayer;\n }\n\n const props = {...this.props};\n delete props.data;\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n updateTriggers\n })\n );\n }\n}\n\nCartoLayer.layerName = 'CartoLayer';\nCartoLayer.defaultProps = defaultProps;\n"],"file":"carto-layer.js"}
1
+ {"version":3,"sources":["../../../src/layers/carto-layer.js"],"names":["defaultProps","data","type","onDataLoad","value","compare","onDataError","optional","uniqueIdProperty","credentials","connection","format","geoColumn","columns","CartoLayer","state","apiVersion","getSubLayers","length","props","localCreds","log","assert","Object","values","API_VERSIONS","includes","V1","V2","MAP_TYPES","QUERY","TILESET","V3","TABLE","Array","isArray","oldProps","changeFlags","_checkProps","shouldUpdateData","dataChanged","JSON","stringify","setState","_updateData","source","rest","localConfig","result","updateTriggers","layer","FORMATS","TILEJSON","MVTLayer","GeoJsonLayer","getSubLayerProps","id","layerName","CompositeLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAInBC,EAAAA,IAAI,EAAE,IAJa;AAKnBC,EAAAA,UAAU,EAAE;AAACD,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,eAAAH,IAAI,EAAI,CAAE,CAApC;AAAsCI,IAAAA,OAAO,EAAE;AAA/C,GALO;AAMnBC,EAAAA,WAAW,EAAE;AAACJ,IAAAA,IAAI,EAAE,UAAP;AAAmBE,IAAAA,KAAK,EAAE,IAA1B;AAAgCC,IAAAA,OAAO,EAAE,KAAzC;AAAgDE,IAAAA,QAAQ,EAAE;AAA1D,GANM;AAOnBC,EAAAA,gBAAgB,EAAE,YAPC;AAUnBC,EAAAA,WAAW,EAAE,IAVM;AAgBnBC,EAAAA,UAAU,EAAE,IAhBO;AAmBnBC,EAAAA,MAAM,EAAE,IAnBW;AAsBnBC,EAAAA,SAAS,EAAE,IAtBQ;AAyBnBC,EAAAA,OAAO,EAAE;AAACX,IAAAA,IAAI,EAAE,OAAP;AAAgBE,IAAAA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AxC;AAAA,UAAOd,IAAP,eAAOA,IAAP;AAAA,UAAaU,MAAb,eAAaA,MAAb;AAAA,UAAqBK,UAArB,eAAqBA,UAArB;AAEA,UAAI,CAACf,IAAL,EAAW,OAAO,IAAP;AAEX,UAAOgD,cAAP,GAAyB,KAAK9B,KAA9B,CAAO8B,cAAP;AAEA,UAAIC,KAAJ;;AAEA,UACElC,UAAU,KAAKS,kBAAaE,EAA5B,IACAX,UAAU,KAAKS,kBAAaG,EAD5B,IAEAjB,MAAM,KAAKwC,uBAAQC,QAHrB,EAIE;AACAF,QAAAA,KAAK,GAAGG,mBAAR;AACD,OAND,MAMO;AACLH,QAAAA,KAAK,GAAGI,oBAAR;AACD;;AAED,UAAO9C,gBAAP,GAA2BR,YAA3B,CAAOQ,gBAAP;;AACA,UAAMW,KAAK;AAAIX,QAAAA,gBAAgB,EAAhBA;AAAJ,SAAyB,KAAKW,KAA9B,CAAX;;AACA,aAAOA,KAAK,CAAClB,IAAb;AAGA,aAAO,IAAIiD,KAAJ,CACL/B,KADK,EAEL,KAAKoC,gBAAL,CAAsB;AACpBC,QAAAA,EAAE,kBAAWN,KAAK,CAACO,SAAjB,CADkB;AAEpBxD,QAAAA,IAAI,EAAJA,IAFoB;AAGpBgD,QAAAA,cAAc,EAAdA;AAHoB,OAAtB,CAFK,CAAP;AAQD;;;EAtHqCS,oB;;;AAyHxC5C,UAAU,CAAC2C,SAAX,GAAuB,YAAvB;AACA3C,UAAU,CAACd,YAAX,GAA0BA,YAA1B","sourcesContent":["import {CompositeLayer, log} from '@deck.gl/core';\nimport {MVTLayer} from '@deck.gl/geo-layers';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {fetchLayerData, getDataV2, API_VERSIONS} from '../api';\nimport {FORMATS, MAP_TYPES} from '../api/maps-api-common';\nimport {getDefaultCredentials} from '../config';\n\nconst defaultProps = {\n // (String, required): data resource to load. table name, sql query or tileset name.\n data: null,\n // (Enum (MAP_TYPES), required)\n type: null,\n onDataLoad: {type: 'function', value: data => {}, compare: false},\n onDataError: {type: 'function', value: null, compare: false, optional: true},\n uniqueIdProperty: 'cartodb_id',\n\n // override carto credentials for the layer, set to null to read from default\n credentials: null,\n\n /*********************/\n /* API v3 PARAMETERS */\n /**********************/\n // (String, required): connection name at CARTO platform\n connection: null,\n\n // (String, optional): format of data\n format: null,\n\n // (String, optional): name of the `geo_column` in the CARTO platform. Use this override the default column ('geom'), from which the geometry information should be fetched.\n geoColumn: null,\n\n // (Array<String>, optional): names of columns to fetch. By default, all columns are fetched.\n columns: {type: 'array', value: null}\n};\n\nexport default class CartoLayer extends CompositeLayer {\n initializeState() {\n this.state = {\n data: null,\n apiVersion: null\n };\n }\n\n get isLoaded() {\n return this.getSubLayers().length > 0 && super.isLoaded;\n }\n\n _checkProps(props) {\n const {type, credentials, connection, geoColumn, columns} = props;\n const localCreds = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localCreds;\n\n log.assert(\n Object.values(API_VERSIONS).includes(apiVersion),\n `Invalid apiVersion ${apiVersion}. Use API_VERSIONS enum.`\n );\n\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n log.assert(\n type === MAP_TYPES.QUERY || type === MAP_TYPES.TILESET,\n `Invalid type ${type}. Use type MAP_TYPES.QUERY or MAP_TYPES.TILESET for apiVersion ${apiVersion}`\n );\n log.assert(!connection, `Connection prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!geoColumn, `geoColumn prop is not supported for apiVersion ${apiVersion}`);\n log.assert(!columns, `columns prop is not supported for apiVersion ${apiVersion}`);\n } else if (apiVersion === API_VERSIONS.V3) {\n log.assert(connection, 'Missing mandatory connection parameter');\n log.assert(\n Object.values(MAP_TYPES).includes(type),\n `Invalid type ${type}. Use MAP_TYPES enum.`\n );\n if (type !== MAP_TYPES.TABLE) {\n log.assert(!geoColumn, `geoColumn prop is only supported for type ${MAP_TYPES.TABLE}`);\n log.assert(!columns, `columns prop is only supported for type ${MAP_TYPES.TABLE}`);\n }\n if (columns) {\n log.assert(Array.isArray(columns), 'columns prop must be an Array');\n }\n }\n }\n\n updateState({props, oldProps, changeFlags}) {\n this._checkProps(props);\n const shouldUpdateData =\n changeFlags.dataChanged ||\n props.connection !== oldProps.connection ||\n props.geoColumn !== oldProps.geoColumn ||\n JSON.stringify(props.columns) !== JSON.stringify(oldProps.columns) ||\n props.type !== oldProps.type ||\n JSON.stringify(props.credentials) !== JSON.stringify(oldProps.credentials);\n\n if (shouldUpdateData) {\n this.setState({data: null, apiVersion: null});\n this._updateData();\n }\n }\n\n async _updateData() {\n try {\n const {type, data: source, credentials, ...rest} = this.props;\n const localConfig = {...getDefaultCredentials(), ...credentials};\n const {apiVersion} = localConfig;\n\n let result;\n if (apiVersion === API_VERSIONS.V1 || apiVersion === API_VERSIONS.V2) {\n result = {data: await getDataV2({type, source, credentials})};\n } else {\n result = await fetchLayerData({type, source, credentials, ...rest});\n }\n\n this.setState({...result, apiVersion});\n this.props.onDataLoad(result.data);\n } catch (err) {\n if (this.props.onDataError) {\n this.props.onDataError(err);\n } else {\n throw err;\n }\n }\n }\n\n renderLayers() {\n const {data, format, apiVersion} = this.state;\n\n if (!data) return null;\n\n const {updateTriggers} = this.props;\n\n let layer;\n\n if (\n apiVersion === API_VERSIONS.V1 ||\n apiVersion === API_VERSIONS.V2 ||\n format === FORMATS.TILEJSON\n ) {\n layer = MVTLayer;\n } else {\n layer = GeoJsonLayer;\n }\n\n const {uniqueIdProperty} = defaultProps;\n const props = {uniqueIdProperty, ...this.props};\n delete props.data;\n\n // eslint-disable-next-line new-cap\n return new layer(\n props,\n this.getSubLayerProps({\n id: `carto-${layer.layerName}`,\n data,\n updateTriggers\n })\n );\n }\n}\n\nCartoLayer.layerName = 'CartoLayer';\nCartoLayer.defaultProps = defaultProps;\n"],"file":"carto-layer.js"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -13,6 +13,10 @@ var _palette = _interopRequireWildcard(require("./palette"));
13
13
 
14
14
  var _utils = require("./utils");
15
15
 
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
16
20
  function colorBins(_ref) {
17
21
  var attr = _ref.attr,
18
22
  domain = _ref.domain,
@@ -21,7 +25,7 @@ function colorBins(_ref) {
21
25
  _ref$nullColor = _ref.nullColor,
22
26
  nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor;
23
27
  (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
24
- var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
28
+ var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length + 1) : colors;
25
29
  var color = (0, _d3Scale.scaleThreshold)().domain(domain).range(palette);
26
30
  return function (d) {
27
31
  var value = (0, _utils.getAttrValue)(attr, d);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-bins-style.js"],"names":["colorBins","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEe,SAASA,SAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAA1B,CAA7B,GAAiEP,MAAjF;AAEA,MAAMQ,KAAK,GAAG,+BACXT,MADW,CACJA,MADI,EAEXU,KAFW,CAELH,OAFK,CAAd;AAIA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCT,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorBins({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n const color = scaleThreshold()\n .domain(domain)\n .range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-bins-style.js"],"names":["colorBins","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,SAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAAP,GAAgB,CAAnC,CAA7B,GAAqEP,MAArF;AAEA,MAAMQ,KAAK,GAAG,+BAAiBT,MAAjB,CAAwBA,MAAxB,EAAgCU,KAAhC,CAAsCH,OAAtC,CAAd;AAEA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCT,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleThreshold} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorBins({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length + 1) : colors;\n\n const color = scaleThreshold().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-bins-style.js"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
@@ -15,7 +15,11 @@ var _palette = _interopRequireWildcard(require("./palette"));
15
15
 
16
16
  var _utils = require("./utils");
17
17
 
18
- function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
19
23
 
20
24
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
25
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;;;;;;;AAEe,SAASA,eAAT,OAMZ;AAAA,MALDC,IAKC,QALDA,IAKC;AAAA,MAJDC,MAIC,QAJDA,MAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQC,wBAGR;AAAA,4BAFDC,SAEC;AAAA,MAFDA,SAEC,+BAFWC,mBAEX;AAAA,8BADDC,WACC;AAAA,MADDA,WACC,iCADaC,qBACb;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,MAAMS,gBAAgB,GAAG,EAAzB;AACA,MAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAJC,6CAMoBD,MAAM,CAACY,OAAP,EANpB;AAAA;;AAAA;AAMD,wDAAuC;AAAA;AAAA,UAA3BC,CAA2B;AAAA,UAAxBC,CAAwB;;AACrCL,MAAAA,gBAAgB,CAACK,CAAD,CAAhB,GAAsBJ,OAAO,CAACG,CAAD,CAA7B;AACD;AARA;AAAA;AAAA;AAAA;AAAA;;AAUD,SAAO,UAAAE,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-categories-style.js"],"names":["colorCategories","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","othersColor","OTHERS_COLOR","Array","isArray","colorsByCategory","palette","length","entries","i","c","d","value","Number","isFinite"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;;;;;;;;;;;AAEe,SAASA,eAAT,OAMZ;AAAA,MALDC,IAKC,QALDA,IAKC;AAAA,MAJDC,MAIC,QAJDA,MAIC;AAAA,yBAHDC,MAGC;AAAA,MAHDA,MAGC,4BAHQC,wBAGR;AAAA,4BAFDC,SAEC;AAAA,MAFDA,SAEC,+BAFWC,mBAEX;AAAA,8BADDC,WACC;AAAA,MADDA,WACC,iCADaC,qBACb;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcR,MAAd,CAAP,EAA8B,wDAA9B;AAEA,MAAMS,gBAAgB,GAAG,EAAzB;AACA,MAAMC,OAAO,GAAG,OAAOT,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACW,MAA1B,CAA7B,GAAiEV,MAAjF;;AAJC,6CAMoBD,MAAM,CAACY,OAAP,EANpB;AAAA;;AAAA;AAMD,wDAAuC;AAAA;AAAA,UAA3BC,CAA2B;AAAA,UAAxBC,CAAwB;;AACrCL,MAAAA,gBAAgB,CAACK,CAAD,CAAhB,GAAsBJ,OAAO,CAACG,CAAD,CAA7B;AACD;AARA;AAAA;AAAA;AAAA;AAAA;;AAUD,SAAO,UAAAE,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAajB,IAAb,EAAmBgB,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,KAA0B,OAAOA,KAAP,KAAiB,QAA3C,GACHP,gBAAgB,CAACO,KAAD,CAAhB,IAA2BX,WADxB,GAEHF,SAFJ;AAGD,GALD;AAMD","sourcesContent":["import getPalette, {DEFAULT_PALETTE, NULL_COLOR, OTHERS_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorCategories({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR,\n othersColor = OTHERS_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers or strings');\n\n const colorsByCategory = {};\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n\n for (const [i, c] of domain.entries()) {\n colorsByCategory[c] = palette[i];\n }\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) || typeof value === 'string'\n ? colorsByCategory[value] || othersColor\n : nullColor;\n };\n}\n"],"file":"color-categories-style.js"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -13,6 +13,10 @@ var _palette = _interopRequireWildcard(require("./palette"));
13
13
 
14
14
  var _utils = require("./utils");
15
15
 
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
16
20
  function colorContinuous(_ref) {
17
21
  var attr = _ref.attr,
18
22
  domain = _ref.domain,
@@ -21,7 +25,7 @@ function colorContinuous(_ref) {
21
25
  _ref$nullColor = _ref.nullColor,
22
26
  nullColor = _ref$nullColor === void 0 ? _palette.NULL_COLOR : _ref$nullColor;
23
27
  (0, _utils.assert)(Array.isArray(domain), 'Expected "domain" to be an array of numbers');
24
- var palette = typeof colors === 'string' ? (0, _palette.default)(colors) : colors;
28
+ var palette = typeof colors === 'string' ? (0, _palette.default)(colors, domain.length) : colors;
25
29
  var color = (0, _d3Scale.scaleLinear)().domain(domain).range(palette);
26
30
  return function (d) {
27
31
  var value = (0, _utils.getAttrValue)(attr, d);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEe,SAASA,eAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,CAA7B,GAAkDA,MAAlE;AACA,MAAMO,KAAK,GAAG,4BACXR,MADW,CACJA,MADI,EAEXS,KAFW,CAELF,OAFK,CAAd;AAIA,SAAO,UAAAG,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAaZ,IAAb,EAAmBW,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCR,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors) : colors;\n const color = scaleLinear()\n .domain(domain)\n .range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
1
+ {"version":3,"sources":["../../../src/style/color-continuous-style.js"],"names":["colorContinuous","attr","domain","colors","DEFAULT_PALETTE","nullColor","NULL_COLOR","Array","isArray","palette","length","color","range","d","value","Number","isFinite"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEe,SAASA,eAAT,OAKZ;AAAA,MAJDC,IAIC,QAJDA,IAIC;AAAA,MAHDC,MAGC,QAHDA,MAGC;AAAA,yBAFDC,MAEC;AAAA,MAFDA,MAEC,4BAFQC,wBAER;AAAA,4BADDC,SACC;AAAA,MADDA,SACC,+BADWC,mBACX;AACD,qBAAOC,KAAK,CAACC,OAAN,CAAcN,MAAd,CAAP,EAA8B,6CAA9B;AAEA,MAAMO,OAAO,GAAG,OAAON,MAAP,KAAkB,QAAlB,GAA6B,sBAAWA,MAAX,EAAmBD,MAAM,CAACQ,MAA1B,CAA7B,GAAiEP,MAAjF;AACA,MAAMQ,KAAK,GAAG,4BAAcT,MAAd,CAAqBA,MAArB,EAA6BU,KAA7B,CAAmCH,OAAnC,CAAd;AAEA,SAAO,UAAAI,CAAC,EAAI;AACV,QAAMC,KAAK,GAAG,yBAAab,IAAb,EAAmBY,CAAnB,CAAd;AACA,WAAOE,MAAM,CAACC,QAAP,CAAgBF,KAAhB,IAAyBH,KAAK,CAACG,KAAD,CAA9B,GAAwCT,SAA/C;AACD,GAHD;AAID","sourcesContent":["import {scaleLinear} from 'd3-scale';\nimport getPalette, {DEFAULT_PALETTE, NULL_COLOR} from './palette';\nimport {assert, getAttrValue} from './utils';\n\nexport default function colorContinuous({\n attr,\n domain,\n colors = DEFAULT_PALETTE,\n nullColor = NULL_COLOR\n}) {\n assert(Array.isArray(domain), 'Expected \"domain\" to be an array of numbers');\n\n const palette = typeof colors === 'string' ? getPalette(colors, domain.length) : colors;\n const color = scaleLinear().domain(domain).range(palette);\n\n return d => {\n const value = getAttrValue(attr, d);\n return Number.isFinite(value) ? color(value) : nullColor;\n };\n}\n"],"file":"color-continuous-style.js"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
@@ -17,6 +17,10 @@ var cartoColors = _interopRequireWildcard(require("cartocolor"));
17
17
 
18
18
  var _utils = require("./utils");
19
19
 
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
20
24
  var DEFAULT_PALETTE = 'PurpOr';
21
25
  exports.DEFAULT_PALETTE = DEFAULT_PALETTE;
22
26
  var NULL_COLOR = [204, 204, 204];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/style/palette.js"],"names":["DEFAULT_PALETTE","NULL_COLOR","OTHERS_COLOR","getPalette","name","numCategories","palette","cartoColors","paletteIndex","palettesColorVariants","Object","keys","filter","p","map","Number","longestPaletteIndex","Math","max","smallestPaletteIndex","min","isInteger","colors","tags","includes","slice","c","hexToRgb","hex","result","exec","parseInt"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAEO,IAAMA,eAAe,GAAG,QAAxB;;AACA,IAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAnB;;AACA,IAAMC,YAAY,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAArB;;;AAEQ,SAASC,UAAT,CAAoBC,IAApB,EAA0BC,aAA1B,EAAyC;AACtD,MAAMC,OAAO,GAAGC,WAAW,CAACH,IAAD,CAA3B;AACA,MAAII,YAAY,GAAGH,aAAnB;AAEA,qBAAOC,OAAP,sBAA4BF,IAA5B;AAEA,MAAMK,qBAAqB,GAAGC,MAAM,CAACC,IAAP,CAAYL,OAAZ,EAC3BM,MAD2B,CACpB,UAAAC,CAAC;AAAA,WAAIA,CAAC,KAAK,MAAV;AAAA,GADmB,EAE3BC,GAF2B,CAEvBC,MAFu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AAP;AACD","sourcesContent":["import * as cartoColors from 'cartocolor';\nimport {assert} from './utils';\n\nexport const DEFAULT_PALETTE = 'PurpOr';\nexport const NULL_COLOR = [204, 204, 204];\nexport const OTHERS_COLOR = [119, 119, 119];\n\nexport default function getPalette(name, numCategories) {\n const palette = cartoColors[name];\n let paletteIndex = numCategories;\n\n assert(palette, `Palette \"${name}\" not found. Expected a CARTOColors string`);\n\n const palettesColorVariants = Object.keys(palette)\n .filter(p => p !== 'tags')\n .map(Number);\n\n const longestPaletteIndex = Math.max(...palettesColorVariants);\n const smallestPaletteIndex = Math.min(...palettesColorVariants);\n\n if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {\n paletteIndex = longestPaletteIndex;\n } else if (numCategories < smallestPaletteIndex) {\n paletteIndex = smallestPaletteIndex;\n }\n\n let colors = palette[paletteIndex];\n\n if (palette.tags && palette.tags.includes('qualitative')) {\n colors = colors.slice(0, -1);\n }\n\n return colors.map(c => hexToRgb(c));\n}\n\nexport function hexToRgb(hex) {\n // Evaluate #ABC\n let result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n 255\n ];\n }\n\n // Evaluate #ABCD\n result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n parseInt(result[4] + result[4], 16)\n ];\n }\n\n // Evaluate #ABCDEF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];\n }\n\n // Evaluate #ABCDEFAF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1], 16),\n parseInt(result[2], 16),\n parseInt(result[3], 16),\n parseInt(result[4], 16)\n ];\n }\n\n assert(result, `Hexadecimal color \"${hex}\" was not parsed correctly`);\n\n return NULL_COLOR;\n}\n"],"file":"palette.js"}
1
+ {"version":3,"sources":["../../../src/style/palette.js"],"names":["DEFAULT_PALETTE","NULL_COLOR","OTHERS_COLOR","getPalette","name","numCategories","palette","cartoColors","paletteIndex","palettesColorVariants","Object","keys","filter","p","map","Number","longestPaletteIndex","Math","max","smallestPaletteIndex","min","isInteger","colors","tags","includes","slice","c","hexToRgb","hex","result","exec","parseInt"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,IAAMA,eAAe,GAAG,QAAxB;;AACA,IAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAnB;;AACA,IAAMC,YAAY,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAArB;;;AAEQ,SAASC,UAAT,CAAoBC,IAApB,EAA0BC,aAA1B,EAAyC;AACtD,MAAMC,OAAO,GAAGC,WAAW,CAACH,IAAD,CAA3B;AACA,MAAII,YAAY,GAAGH,aAAnB;AAEA,qBAAOC,OAAP,sBAA4BF,IAA5B;AAEA,MAAMK,qBAAqB,GAAGC,MAAM,CAACC,IAAP,CAAYL,OAAZ,EAC3BM,MAD2B,CACpB,UAAAC,CAAC;AAAA,WAAIA,CAAC,KAAK,MAAV;AAAA,GADmB,EAE3BC,GAF2B,CAEvBC,MAFuB,CAA9B;AAIA,MAAMC,mBAAmB,GAAGC,IAAI,CAACC,GAAL,OAAAD,IAAI,mCAAQR,qBAAR,EAAhC;AACA,MAAMU,oBAAoB,GAAGF,IAAI,CAACG,GAAL,OAAAH,IAAI,mCAAQR,qBAAR,EAAjC;;AAEA,MAAI,CAACM,MAAM,CAACM,SAAP,CAAiBhB,aAAjB,CAAD,IAAoCA,aAAa,G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AAD,CAAnB,EAAwB,EAAxB,CAFH,EAGLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAnB,EAAwB,EAAxB,CAHH,EAILE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAnB,EAAwB,EAAxB,CAJH,CAAP;AAMD;;AAGDA,EAAAA,MAAM,GAAG,4CAA4CC,IAA5C,CAAiDF,GAAjD,CAAT;;AAEA,MAAIC,MAAJ,EAAY;AACV,WAAO,CAACE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAAT,EAA0BE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAAlC,EAAmDE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAA3D,EAA4E,GAA5E,CAAP;AACD;;AAGDA,EAAAA,MAAM,GAAG,wDAAwDC,IAAxD,CAA6DF,GAA7D,CAAT;;AAEA,MAAIC,MAAJ,EAAY;AACV,WAAO,CACLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CADH,EAELE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAFH,EAGLE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAHH,EAILE,QAAQ,CAACF,MAAM,CAAC,CAAD,CAAP,EAAY,EAAZ,CAJH,CAAP;AAMD;;AAED,qBAAOA,MAAP,gCAAqCD,GAArC;AAEA,SAAO3B,UAAP;AACD","sourcesContent":["import * as cartoColors from 'cartocolor';\nimport {assert} from './utils';\n\nexport const DEFAULT_PALETTE = 'PurpOr';\nexport const NULL_COLOR = [204, 204, 204];\nexport const OTHERS_COLOR = [119, 119, 119];\n\nexport default function getPalette(name, numCategories) {\n const palette = cartoColors[name];\n let paletteIndex = numCategories;\n\n assert(palette, `Palette \"${name}\" not found. Expected a CARTOColors string`);\n\n const palettesColorVariants = Object.keys(palette)\n .filter(p => p !== 'tags')\n .map(Number);\n\n const longestPaletteIndex = Math.max(...palettesColorVariants);\n const smallestPaletteIndex = Math.min(...palettesColorVariants);\n\n if (!Number.isInteger(numCategories) || numCategories > longestPaletteIndex) {\n paletteIndex = longestPaletteIndex;\n } else if (numCategories < smallestPaletteIndex) {\n paletteIndex = smallestPaletteIndex;\n }\n\n let colors = palette[paletteIndex];\n\n if (palette.tags && palette.tags.includes('qualitative')) {\n colors = colors.slice(0, -1);\n }\n\n return colors.map(c => hexToRgb(c));\n}\n\nexport function hexToRgb(hex) {\n // Evaluate #ABC\n let result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n 255\n ];\n }\n\n // Evaluate #ABCD\n result = /^#?([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})([a-f\\d]{1})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1] + result[1], 16),\n parseInt(result[2] + result[2], 16),\n parseInt(result[3] + result[3], 16),\n parseInt(result[4] + result[4], 16)\n ];\n }\n\n // Evaluate #ABCDEF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16), 255];\n }\n\n // Evaluate #ABCDEFAF\n result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n\n if (result) {\n return [\n parseInt(result[1], 16),\n parseInt(result[2], 16),\n parseInt(result[3], 16),\n parseInt(result[4], 16)\n ];\n }\n\n assert(result, `Hexadecimal color \"${hex}\" was not parsed correctly`);\n\n return NULL_COLOR;\n}\n"],"file":"palette.js"}
@@ -17,6 +17,7 @@ const SCALE_FUNCS = {
17
17
  const sharedPropMap = {
18
18
  color: 'getFillColor',
19
19
  isVisible: 'visible',
20
+ label: 'cartoLabel',
20
21
  textLabel: {
21
22
  alignment: 'getTextAlignmentBaseline',
22
23
  anchor: 'getTextAnchor',
@@ -128,7 +129,7 @@ function calculateDomain(data, name, scaleType) {
128
129
  properties
129
130
  }) => properties[name]);
130
131
  return domainFromValues(values, scaleType);
131
- } else if (Array.isArray(data) && data[0][name]) {
132
+ } else if (Array.isArray(data) && data[0][name] !== undefined) {
132
133
  const values = data.map(properties => properties[name]);
133
134
  return domainFromValues(values, scaleType);
134
135
  }
@@ -156,7 +157,7 @@ export function getColorAccessor({
156
157
  const scale = SCALE_FUNCS[scaleType]();
157
158
  scale.domain(calculateDomain(data, name, scaleType));
158
159
  scale.range(colors);
159
- const alpha = opacity !== undefined ? 255 * Math.pow(opacity, 1 / 2.2) : 255;
160
+ const alpha = opacity !== undefined ? Math.round(255 * Math.pow(opacity, 1 / 2.2)) : 255;
160
161
 
161
162
  const accessor = properties => {
162
163
  const rgba = rgb(scale(properties[name]));