@deck.gl/geo-layers 8.6.4 → 8.6.5

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 (53) hide show
  1. package/dist/dist.dev.js +35 -15
  2. package/dist/es5/great-circle-layer/great-circle-layer.js +26 -1
  3. package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
  4. package/dist/es5/h3-layers/h3-cluster-layer.js +149 -87
  5. package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
  6. package/dist/es5/h3-layers/h3-hexagon-layer.js +321 -226
  7. package/dist/es5/h3-layers/h3-hexagon-layer.js.map +1 -1
  8. package/dist/es5/index.js +9 -9
  9. package/dist/es5/mesh-layer/mesh-layer.js +151 -125
  10. package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
  11. package/dist/es5/mvt-layer/coordinate-transform.js +45 -19
  12. package/dist/es5/mvt-layer/coordinate-transform.js.map +1 -1
  13. package/dist/es5/mvt-layer/find-index-binary.js +45 -26
  14. package/dist/es5/mvt-layer/find-index-binary.js.map +1 -1
  15. package/dist/es5/mvt-layer/mvt-layer.js +394 -279
  16. package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
  17. package/dist/es5/s2-layer/s2-geometry.js +43 -32
  18. package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
  19. package/dist/es5/s2-layer/s2-layer.js +104 -69
  20. package/dist/es5/s2-layer/s2-layer.js.map +1 -1
  21. package/dist/es5/s2-layer/s2-utils.js +27 -28
  22. package/dist/es5/s2-layer/s2-utils.js.map +1 -1
  23. package/dist/es5/terrain-layer/terrain-layer.js +250 -208
  24. package/dist/es5/terrain-layer/terrain-layer.js.map +1 -1
  25. package/dist/es5/tile-3d-layer/tile-3d-layer.js +382 -329
  26. package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
  27. package/dist/es5/tile-layer/tile-2d-header.js +183 -119
  28. package/dist/es5/tile-layer/tile-2d-header.js.map +1 -1
  29. package/dist/es5/tile-layer/tile-2d-traversal.js +178 -115
  30. package/dist/es5/tile-layer/tile-2d-traversal.js.map +1 -1
  31. package/dist/es5/tile-layer/tile-layer.js +257 -214
  32. package/dist/es5/tile-layer/tile-layer.js.map +1 -1
  33. package/dist/es5/tile-layer/tileset-2d.js +435 -290
  34. package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
  35. package/dist/es5/tile-layer/utils.js +110 -61
  36. package/dist/es5/tile-layer/utils.js.map +1 -1
  37. package/dist/es5/trips-layer/trips-layer.js +81 -44
  38. package/dist/es5/trips-layer/trips-layer.js.map +1 -1
  39. package/dist/esm/mvt-layer/mvt-layer.js +26 -0
  40. package/dist/esm/mvt-layer/mvt-layer.js.map +1 -1
  41. package/dist/esm/terrain-layer/terrain-layer.js +8 -10
  42. package/dist/esm/terrain-layer/terrain-layer.js.map +1 -1
  43. package/dist/esm/tile-3d-layer/tile-3d-layer.js.map +1 -1
  44. package/dist/esm/tile-layer/tile-2d-header.js.map +1 -1
  45. package/dist/esm/tile-layer/tile-2d-traversal.js.map +1 -1
  46. package/dist/esm/tile-layer/tile-layer.js +6 -8
  47. package/dist/esm/tile-layer/tile-layer.js.map +1 -1
  48. package/dist/esm/tile-layer/tileset-2d.js.map +1 -1
  49. package/dist.min.js +1 -1
  50. package/package.json +2 -2
  51. package/src/mvt-layer/mvt-layer.js +16 -0
  52. package/src/terrain-layer/terrain-layer.js +10 -9
  53. package/src/tile-layer/tile-layer.js +9 -6
@@ -7,6 +7,26 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
+
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
+
18
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
+
20
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
+
22
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
23
+
24
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
+
26
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
27
+
28
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
29
+
10
30
  var _core = require("@deck.gl/core");
11
31
 
12
32
  var _math = require("math.gl");
@@ -27,8 +47,22 @@ var _findIndexBinary = _interopRequireDefault(require("./find-index-binary"));
27
47
 
28
48
  var _layers = require("@deck.gl/layers");
29
49
 
30
- const WORLD_SIZE = 512;
31
- const defaultProps = {
50
+ 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; } } }; }
51
+
52
+ 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); }
53
+
54
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
55
+
56
+ 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; }
57
+
58
+ 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; }
59
+
60
+ 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); }; }
61
+
62
+ 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; } }
63
+
64
+ var WORLD_SIZE = 512;
65
+ var defaultProps = {
32
66
  uniqueIdProperty: {
33
67
  type: 'string',
34
68
  value: ''
@@ -38,328 +72,408 @@ const defaultProps = {
38
72
  binary: true
39
73
  };
40
74
 
41
- class MVTLayer extends _tileLayer.default {
42
- initializeState() {
43
- super.initializeState();
44
- this.setState({
45
- data: null,
46
- tileJSON: null
47
- });
48
- }
75
+ var MVTLayer = function (_TileLayer) {
76
+ (0, _inherits2.default)(MVTLayer, _TileLayer);
49
77
 
50
- get isLoaded() {
51
- return this.state.data && this.state.tileset && super.isLoaded;
52
- }
78
+ var _super = _createSuper(MVTLayer);
53
79
 
54
- updateState({
55
- props,
56
- oldProps,
57
- context,
58
- changeFlags
59
- }) {
60
- if (changeFlags.dataChanged) {
61
- this._updateTileData();
62
- }
63
-
64
- if (this.state.data) {
65
- super.updateState({
66
- props,
67
- oldProps,
68
- context,
69
- changeFlags
70
- });
71
-
72
- this._setWGS84PropertyForTiles();
73
- }
80
+ function MVTLayer() {
81
+ (0, _classCallCheck2.default)(this, MVTLayer);
82
+ return _super.apply(this, arguments);
74
83
  }
75
84
 
76
- async _updateTileData() {
77
- let {
78
- data
79
- } = this.props;
80
- let tileJSON = null;
81
-
82
- if (typeof data === 'string' && !(0, _utils.isURLTemplate)(data)) {
83
- const {
84
- onDataLoad,
85
- fetch
86
- } = this.props;
85
+ (0, _createClass2.default)(MVTLayer, [{
86
+ key: "initializeState",
87
+ value: function initializeState() {
88
+ (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "initializeState", this).call(this);
87
89
  this.setState({
88
90
  data: null,
89
91
  tileJSON: null
90
92
  });
93
+ }
94
+ }, {
95
+ key: "updateState",
96
+ value: function updateState(_ref) {
97
+ var props = _ref.props,
98
+ oldProps = _ref.oldProps,
99
+ context = _ref.context,
100
+ changeFlags = _ref.changeFlags;
101
+
102
+ if (changeFlags.dataChanged) {
103
+ this._updateTileData();
104
+ }
91
105
 
92
- try {
93
- tileJSON = await fetch(data, {
94
- propName: 'data',
95
- layer: this,
96
- loaders: []
106
+ if (this.state.data) {
107
+ (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "updateState", this).call(this, {
108
+ props: props,
109
+ oldProps: oldProps,
110
+ context: context,
111
+ changeFlags: changeFlags
97
112
  });
98
- } catch (error) {
99
- this.raiseError(error, 'loading TileJSON');
100
- data = null;
101
- }
102
113
 
103
- if (onDataLoad) {
104
- onDataLoad(tileJSON);
114
+ this._setWGS84PropertyForTiles();
105
115
  }
106
- } else if (data.tilejson) {
107
- tileJSON = data;
108
- }
109
-
110
- if (tileJSON) {
111
- data = tileJSON.tiles;
112
- }
113
-
114
- this.setState({
115
- data,
116
- tileJSON
117
- });
118
- }
119
116
 
120
- _getTilesetOptions(props) {
121
- const opts = super._getTilesetOptions(props);
117
+ var highlightColor = props.highlightColor;
122
118
 
123
- const {
124
- tileJSON
125
- } = this.state;
126
-
127
- if (tileJSON) {
128
- if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > props.minZoom) {
129
- opts.minZoom = tileJSON.minzoom;
130
- }
131
-
132
- if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)) {
133
- opts.maxZoom = tileJSON.maxzoom;
119
+ if (highlightColor !== oldProps.highlightColor && Array.isArray(highlightColor)) {
120
+ this.setState({
121
+ highlightColor: highlightColor
122
+ });
134
123
  }
135
124
  }
125
+ }, {
126
+ key: "_updateTileData",
127
+ value: function () {
128
+ var _updateTileData2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
129
+ var data, tileJSON, _this$props, onDataLoad, fetch;
130
+
131
+ return _regenerator.default.wrap(function _callee$(_context) {
132
+ while (1) {
133
+ switch (_context.prev = _context.next) {
134
+ case 0:
135
+ data = this.props.data;
136
+ tileJSON = null;
137
+
138
+ if (!(typeof data === 'string' && !(0, _utils.isURLTemplate)(data))) {
139
+ _context.next = 18;
140
+ break;
141
+ }
142
+
143
+ _this$props = this.props, onDataLoad = _this$props.onDataLoad, fetch = _this$props.fetch;
144
+ this.setState({
145
+ data: null,
146
+ tileJSON: null
147
+ });
148
+ _context.prev = 5;
149
+ _context.next = 8;
150
+ return fetch(data, {
151
+ propName: 'data',
152
+ layer: this,
153
+ loaders: []
154
+ });
155
+
156
+ case 8:
157
+ tileJSON = _context.sent;
158
+ _context.next = 15;
159
+ break;
160
+
161
+ case 11:
162
+ _context.prev = 11;
163
+ _context.t0 = _context["catch"](5);
164
+ this.raiseError(_context.t0, 'loading TileJSON');
165
+ data = null;
166
+
167
+ case 15:
168
+ if (onDataLoad) {
169
+ onDataLoad(tileJSON);
170
+ }
171
+
172
+ _context.next = 19;
173
+ break;
174
+
175
+ case 18:
176
+ if (data.tilejson) {
177
+ tileJSON = data;
178
+ }
179
+
180
+ case 19:
181
+ if (tileJSON) {
182
+ data = tileJSON.tiles;
183
+ }
184
+
185
+ this.setState({
186
+ data: data,
187
+ tileJSON: tileJSON
188
+ });
189
+
190
+ case 21:
191
+ case "end":
192
+ return _context.stop();
193
+ }
194
+ }
195
+ }, _callee, this, [[5, 11]]);
196
+ }));
136
197
 
137
- return opts;
138
- }
139
-
140
- renderLayers() {
141
- if (!this.state.data) return null;
142
- return super.renderLayers();
143
- }
144
-
145
- getTileData(tile) {
146
- var _loadOptions;
147
-
148
- const url = (0, _utils.getURLFromTemplate)(this.state.data, tile);
198
+ function _updateTileData() {
199
+ return _updateTileData2.apply(this, arguments);
200
+ }
149
201
 
150
- if (!url) {
151
- return Promise.reject('Invalid URL');
152
- }
202
+ return _updateTileData;
203
+ }()
204
+ }, {
205
+ key: "_getTilesetOptions",
206
+ value: function _getTilesetOptions(props) {
207
+ var opts = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "_getTilesetOptions", this).call(this, props);
208
+ var tileJSON = this.state.tileJSON;
209
+
210
+ if (tileJSON) {
211
+ if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > props.minZoom) {
212
+ opts.minZoom = tileJSON.minzoom;
213
+ }
153
214
 
154
- let loadOptions = this.getLoadOptions();
155
- const {
156
- binary,
157
- fetch
158
- } = this.props;
159
- const {
160
- signal,
161
- x,
162
- y,
163
- z
164
- } = tile;
165
- loadOptions = { ...loadOptions,
166
- mimeType: 'application/x-protobuf',
167
- mvt: { ...((_loadOptions = loadOptions) === null || _loadOptions === void 0 ? void 0 : _loadOptions.mvt),
168
- coordinates: this.context.viewport.resolution ? 'wgs84' : 'local',
169
- tileIndex: {
170
- x,
171
- y,
172
- z
215
+ if (Number.isFinite(tileJSON.maxzoom) && (!Number.isFinite(props.maxZoom) || tileJSON.maxzoom < props.maxZoom)) {
216
+ opts.maxZoom = tileJSON.maxzoom;
173
217
  }
174
- },
175
- gis: binary ? {
176
- format: 'binary'
177
- } : {}
178
- };
179
- return fetch(url, {
180
- propName: 'data',
181
- layer: this,
182
- loadOptions,
183
- signal
184
- });
185
- }
218
+ }
186
219
 
187
- renderSubLayers(props) {
188
- const {
189
- tile
190
- } = props;
191
- const worldScale = Math.pow(2, tile.z);
192
- const xScale = WORLD_SIZE / worldScale;
193
- const yScale = -xScale;
194
- const xOffset = WORLD_SIZE * tile.x / worldScale;
195
- const yOffset = WORLD_SIZE * (1 - tile.y / worldScale);
196
- const modelMatrix = new _math.Matrix4().scale([xScale, yScale, 1]);
197
- props.autoHighlight = false;
198
-
199
- if (!this.context.viewport.resolution) {
200
- props.modelMatrix = modelMatrix;
201
- props.coordinateOrigin = [xOffset, yOffset, 0];
202
- props.coordinateSystem = _core.COORDINATE_SYSTEM.CARTESIAN;
203
- props.extensions = [...(props.extensions || []), new _extensions.ClipExtension()];
220
+ return opts;
204
221
  }
205
-
206
- const subLayers = super.renderSubLayers(props);
207
-
208
- if (this.props.binary && !(subLayers instanceof _layers.GeoJsonLayer)) {
209
- _core.log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
222
+ }, {
223
+ key: "renderLayers",
224
+ value: function renderLayers() {
225
+ if (!this.state.data) return null;
226
+ return (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "renderLayers", this).call(this);
210
227
  }
228
+ }, {
229
+ key: "getTileData",
230
+ value: function getTileData(tile) {
231
+ var _loadOptions;
211
232
 
212
- return subLayers;
213
- }
233
+ var url = (0, _utils.getURLFromTemplate)(this.state.data, tile);
214
234
 
215
- _updateAutoHighlight(info) {
216
- const {
217
- uniqueIdProperty
218
- } = this.props;
219
- const {
220
- hoveredFeatureId,
221
- hoveredFeatureLayerName
222
- } = this.state;
223
- const hoveredFeature = info.object;
224
- let newHoveredFeatureId;
225
- let newHoveredFeatureLayerName;
226
-
227
- if (hoveredFeature) {
228
- newHoveredFeatureId = getFeatureUniqueId(hoveredFeature, uniqueIdProperty);
229
- newHoveredFeatureLayerName = getFeatureLayerName(hoveredFeature);
230
- }
235
+ if (!url) {
236
+ return Promise.reject('Invalid URL');
237
+ }
231
238
 
232
- if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
233
- this.setState({
234
- hoveredFeatureId: newHoveredFeatureId,
235
- hoveredFeatureLayerName: newHoveredFeatureLayerName
239
+ var loadOptions = this.getLoadOptions();
240
+ var _this$props2 = this.props,
241
+ binary = _this$props2.binary,
242
+ fetch = _this$props2.fetch;
243
+ var signal = tile.signal,
244
+ x = tile.x,
245
+ y = tile.y,
246
+ z = tile.z;
247
+ loadOptions = _objectSpread(_objectSpread({}, loadOptions), {}, {
248
+ mimeType: 'application/x-protobuf',
249
+ mvt: _objectSpread(_objectSpread({}, (_loadOptions = loadOptions) === null || _loadOptions === void 0 ? void 0 : _loadOptions.mvt), {}, {
250
+ coordinates: this.context.viewport.resolution ? 'wgs84' : 'local',
251
+ tileIndex: {
252
+ x: x,
253
+ y: y,
254
+ z: z
255
+ }
256
+ }),
257
+ gis: binary ? {
258
+ format: 'binary'
259
+ } : {}
236
260
  });
237
- }
238
- }
239
-
240
- getPickingInfo(params) {
241
- const info = super.getPickingInfo(params);
242
- const isWGS84 = this.context.viewport.resolution;
243
-
244
- if (this.props.binary && info.index !== -1) {
245
- const {
246
- data
247
- } = params.sourceLayer.props;
248
- info.object = (0, _gis.binaryToGeojson)(data, {
249
- globalFeatureId: info.index
261
+ return fetch(url, {
262
+ propName: 'data',
263
+ layer: this,
264
+ loadOptions: loadOptions,
265
+ signal: signal
250
266
  });
251
267
  }
268
+ }, {
269
+ key: "renderSubLayers",
270
+ value: function renderSubLayers(props) {
271
+ var tile = props.tile;
272
+ var worldScale = Math.pow(2, tile.z);
273
+ var xScale = WORLD_SIZE / worldScale;
274
+ var yScale = -xScale;
275
+ var xOffset = WORLD_SIZE * tile.x / worldScale;
276
+ var yOffset = WORLD_SIZE * (1 - tile.y / worldScale);
277
+ var modelMatrix = new _math.Matrix4().scale([xScale, yScale, 1]);
278
+ props.autoHighlight = false;
279
+
280
+ if (!this.context.viewport.resolution) {
281
+ props.modelMatrix = modelMatrix;
282
+ props.coordinateOrigin = [xOffset, yOffset, 0];
283
+ props.coordinateSystem = _core.COORDINATE_SYSTEM.CARTESIAN;
284
+ props.extensions = [].concat((0, _toConsumableArray2.default)(props.extensions || []), [new _extensions.ClipExtension()]);
285
+ }
252
286
 
253
- if (info.object && !isWGS84) {
254
- info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
255
- }
287
+ var subLayers = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "renderSubLayers", this).call(this, props);
256
288
 
257
- return info;
258
- }
289
+ if (this.props.binary && !(subLayers instanceof _layers.GeoJsonLayer)) {
290
+ _core.log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
291
+ }
259
292
 
260
- getHighlightedObjectIndex(tile) {
261
- const {
262
- hoveredFeatureId,
263
- hoveredFeatureLayerName
264
- } = this.state;
265
- const {
266
- uniqueIdProperty,
267
- highlightedFeatureId,
268
- binary
269
- } = this.props;
270
- const data = tile.content;
271
- const isHighlighted = isFeatureIdDefined(highlightedFeatureId);
272
- const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId) || isHighlighted;
273
-
274
- if (!isFeatureIdPresent) {
275
- return -1;
293
+ return subLayers;
276
294
  }
295
+ }, {
296
+ key: "_updateAutoHighlight",
297
+ value: function _updateAutoHighlight(info) {
298
+ var uniqueIdProperty = this.props.uniqueIdProperty;
299
+ var _this$state = this.state,
300
+ hoveredFeatureId = _this$state.hoveredFeatureId,
301
+ hoveredFeatureLayerName = _this$state.hoveredFeatureLayerName;
302
+ var hoveredFeature = info.object;
303
+ var newHoveredFeatureId;
304
+ var newHoveredFeatureLayerName;
305
+
306
+ if (hoveredFeature) {
307
+ newHoveredFeatureId = getFeatureUniqueId(hoveredFeature, uniqueIdProperty);
308
+ newHoveredFeatureLayerName = getFeatureLayerName(hoveredFeature);
309
+ }
277
310
 
278
- const featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
279
-
280
- if (Array.isArray(data)) {
281
- return data.findIndex(feature => {
282
- const isMatchingId = getFeatureUniqueId(feature, uniqueIdProperty) === featureIdToHighlight;
283
- const isMatchingLayer = isHighlighted || getFeatureLayerName(feature) === hoveredFeatureLayerName;
284
- return isMatchingId && isMatchingLayer;
285
- });
286
- } else if (data && binary) {
287
- return (0, _findIndexBinary.default)(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? '' : hoveredFeatureLayerName);
288
- }
311
+ var highlightColor = this.props.highlightColor;
289
312
 
290
- return -1;
291
- }
313
+ if (typeof highlightColor === 'function') {
314
+ highlightColor = highlightColor(info);
315
+ }
292
316
 
293
- _pickObjects(maxObjects) {
294
- const {
295
- deck,
296
- viewport
297
- } = this.context;
298
- const width = viewport.width;
299
- const height = viewport.height;
300
- const x = viewport.x;
301
- const y = viewport.y;
302
- const layerIds = [this.id];
303
- return deck.pickObjects({
304
- x,
305
- y,
306
- width,
307
- height,
308
- layerIds,
309
- maxObjects
310
- });
311
- }
317
+ if (hoveredFeatureId !== newHoveredFeatureId || hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
318
+ this.setState({
319
+ highlightColor: highlightColor,
320
+ hoveredFeatureId: newHoveredFeatureId,
321
+ hoveredFeatureLayerName: newHoveredFeatureLayerName
322
+ });
323
+ }
324
+ }
325
+ }, {
326
+ key: "getPickingInfo",
327
+ value: function getPickingInfo(params) {
328
+ var info = (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "getPickingInfo", this).call(this, params);
329
+ var isWGS84 = this.context.viewport.resolution;
330
+
331
+ if (this.props.binary && info.index !== -1) {
332
+ var data = params.sourceLayer.props.data;
333
+ info.object = (0, _gis.binaryToGeojson)(data, {
334
+ globalFeatureId: info.index
335
+ });
336
+ }
312
337
 
313
- getRenderedFeatures(maxFeatures = null) {
314
- const features = this._pickObjects(maxFeatures);
338
+ if (info.object && !isWGS84) {
339
+ info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
340
+ }
315
341
 
316
- const featureCache = new Set();
317
- const renderedFeatures = [];
342
+ return info;
343
+ }
344
+ }, {
345
+ key: "getSubLayerPropsByTile",
346
+ value: function getSubLayerPropsByTile(tile) {
347
+ return {
348
+ highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
349
+ highlightColor: this.state.highlightColor
350
+ };
351
+ }
352
+ }, {
353
+ key: "getHighlightedObjectIndex",
354
+ value: function getHighlightedObjectIndex(tile) {
355
+ var _this$state2 = this.state,
356
+ hoveredFeatureId = _this$state2.hoveredFeatureId,
357
+ hoveredFeatureLayerName = _this$state2.hoveredFeatureLayerName;
358
+ var _this$props3 = this.props,
359
+ uniqueIdProperty = _this$props3.uniqueIdProperty,
360
+ highlightedFeatureId = _this$props3.highlightedFeatureId,
361
+ binary = _this$props3.binary;
362
+ var data = tile.content;
363
+ var isHighlighted = isFeatureIdDefined(highlightedFeatureId);
364
+ var isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId) || isHighlighted;
365
+
366
+ if (!isFeatureIdPresent) {
367
+ return -1;
368
+ }
318
369
 
319
- for (const f of features) {
320
- const featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
370
+ var featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
321
371
 
322
- if (featureId === undefined) {
323
- renderedFeatures.push(f.object);
324
- } else if (!featureCache.has(featureId)) {
325
- featureCache.add(featureId);
326
- renderedFeatures.push(f.object);
372
+ if (Array.isArray(data)) {
373
+ return data.findIndex(function (feature) {
374
+ var isMatchingId = getFeatureUniqueId(feature, uniqueIdProperty) === featureIdToHighlight;
375
+ var isMatchingLayer = isHighlighted || getFeatureLayerName(feature) === hoveredFeatureLayerName;
376
+ return isMatchingId && isMatchingLayer;
377
+ });
378
+ } else if (data && binary) {
379
+ return (0, _findIndexBinary.default)(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? '' : hoveredFeatureLayerName);
327
380
  }
328
- }
329
381
 
330
- return renderedFeatures;
331
- }
382
+ return -1;
383
+ }
384
+ }, {
385
+ key: "_pickObjects",
386
+ value: function _pickObjects(maxObjects) {
387
+ var _this$context = this.context,
388
+ deck = _this$context.deck,
389
+ viewport = _this$context.viewport;
390
+ var width = viewport.width;
391
+ var height = viewport.height;
392
+ var x = viewport.x;
393
+ var y = viewport.y;
394
+ var layerIds = [this.id];
395
+ return deck.pickObjects({
396
+ x: x,
397
+ y: y,
398
+ width: width,
399
+ height: height,
400
+ layerIds: layerIds,
401
+ maxObjects: maxObjects
402
+ });
403
+ }
404
+ }, {
405
+ key: "getRenderedFeatures",
406
+ value: function getRenderedFeatures() {
407
+ var maxFeatures = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
332
408
 
333
- _setWGS84PropertyForTiles() {
334
- const propName = 'dataInWGS84';
335
- const {
336
- tileset
337
- } = this.state;
338
- tileset.selectedTiles.forEach(tile => {
339
- if (!tile.hasOwnProperty(propName)) {
340
- Object.defineProperty(tile, propName, {
341
- get: () => {
342
- if (!tile.content) {
343
- return null;
344
- }
409
+ var features = this._pickObjects(maxFeatures);
345
410
 
346
- if (this.props.binary && Array.isArray(tile.content) && !tile.content.length) {
347
- return [];
348
- }
411
+ var featureCache = new Set();
412
+ var renderedFeatures = [];
349
413
 
350
- if (tile._contentWGS84 === undefined) {
351
- const content = this.props.binary ? (0, _gis.binaryToGeojson)(tile.content) : tile.content;
352
- tile._contentWGS84 = content.map(feature => transformTileCoordsToWGS84(feature, tile.bbox, this.context.viewport));
353
- }
414
+ var _iterator = _createForOfIteratorHelper(features),
415
+ _step;
354
416
 
355
- return tile._contentWGS84;
417
+ try {
418
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
419
+ var f = _step.value;
420
+ var featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
421
+
422
+ if (featureId === undefined) {
423
+ renderedFeatures.push(f.object);
424
+ } else if (!featureCache.has(featureId)) {
425
+ featureCache.add(featureId);
426
+ renderedFeatures.push(f.object);
356
427
  }
357
- });
428
+ }
429
+ } catch (err) {
430
+ _iterator.e(err);
431
+ } finally {
432
+ _iterator.f();
358
433
  }
359
- });
360
- }
361
434
 
362
- }
435
+ return renderedFeatures;
436
+ }
437
+ }, {
438
+ key: "_setWGS84PropertyForTiles",
439
+ value: function _setWGS84PropertyForTiles() {
440
+ var _this = this;
441
+
442
+ var propName = 'dataInWGS84';
443
+ var tileset = this.state.tileset;
444
+ tileset.selectedTiles.forEach(function (tile) {
445
+ if (!tile.hasOwnProperty(propName)) {
446
+ Object.defineProperty(tile, propName, {
447
+ get: function get() {
448
+ if (!tile.content) {
449
+ return null;
450
+ }
451
+
452
+ if (_this.props.binary && Array.isArray(tile.content) && !tile.content.length) {
453
+ return [];
454
+ }
455
+
456
+ if (tile._contentWGS84 === undefined) {
457
+ var content = _this.props.binary ? (0, _gis.binaryToGeojson)(tile.content) : tile.content;
458
+ tile._contentWGS84 = content.map(function (feature) {
459
+ return transformTileCoordsToWGS84(feature, tile.bbox, _this.context.viewport);
460
+ });
461
+ }
462
+
463
+ return tile._contentWGS84;
464
+ }
465
+ });
466
+ }
467
+ });
468
+ }
469
+ }, {
470
+ key: "isLoaded",
471
+ get: function get() {
472
+ return this.state.data && this.state.tileset && (0, _get2.default)((0, _getPrototypeOf2.default)(MVTLayer.prototype), "isLoaded", this);
473
+ }
474
+ }]);
475
+ return MVTLayer;
476
+ }(_tileLayer.default);
363
477
 
364
478
  exports.default = MVTLayer;
365
479
 
@@ -386,14 +500,15 @@ function isFeatureIdDefined(value) {
386
500
  }
387
501
 
388
502
  function transformTileCoordsToWGS84(object, bbox, viewport) {
389
- const feature = { ...object,
503
+ var feature = _objectSpread(_objectSpread({}, object), {}, {
390
504
  geometry: {
391
505
  type: object.geometry.type
392
506
  }
393
- };
507
+ });
508
+
394
509
  Object.defineProperty(feature.geometry, 'coordinates', {
395
- get: () => {
396
- const wgs84Geom = (0, _coordinateTransform.transform)(object.geometry, bbox, viewport);
510
+ get: function get() {
511
+ var wgs84Geom = (0, _coordinateTransform.transform)(object.geometry, bbox, viewport);
397
512
  return wgs84Geom.coordinates;
398
513
  }
399
514
  });