@deck.gl/mapbox 8.6.0-beta.1 → 8.6.3

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.
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -11,23 +9,21 @@ exports.removeLayer = removeLayer;
11
9
  exports.updateLayer = updateLayer;
12
10
  exports.drawLayer = drawLayer;
13
11
 
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
12
  var _core = require("@deck.gl/core");
17
13
 
18
- function getDeckInstance(_ref) {
19
- var map = _ref.map,
20
- gl = _ref.gl,
21
- deck = _ref.deck;
22
-
14
+ function getDeckInstance({
15
+ map,
16
+ gl,
17
+ deck
18
+ }) {
23
19
  if (map.__deck) {
24
20
  return map.__deck;
25
21
  }
26
22
 
27
- var customRender = deck && deck.props._customRender;
28
- var deckProps = {
23
+ const customRender = deck && deck.props._customRender;
24
+ const deckProps = {
29
25
  useDevicePixels: true,
30
- _customRender: function _customRender() {
26
+ _customRender: () => {
31
27
  map.triggerRepaint();
32
28
 
33
29
  if (customRender) {
@@ -51,17 +47,15 @@ function getDeckInstance(_ref) {
51
47
  deck.props.userData.isExternal = true;
52
48
  } else {
53
49
  Object.assign(deckProps, {
54
- gl: gl,
50
+ gl,
55
51
  width: false,
56
52
  height: false,
57
53
  touchAction: 'unset',
58
54
  viewState: getViewState(map)
59
55
  });
60
56
  deck = new _core.Deck(deckProps);
61
- map.on('move', function () {
62
- return onMapMove(deck, map);
63
- });
64
- map.on('remove', function () {
57
+ map.on('move', () => onMapMove(deck, map));
58
+ map.on('remove', () => {
65
59
  deck.finalize();
66
60
  map.__deck = null;
67
61
  });
@@ -69,7 +63,7 @@ function getDeckInstance(_ref) {
69
63
 
70
64
  deck.props.userData.mapboxVersion = getMapboxVersion(map);
71
65
  map.__deck = deck;
72
- map.on('render', function () {
66
+ map.on('render', () => {
73
67
  if (deck.layerManager) afterRender(deck, map);
74
68
  });
75
69
  return deck;
@@ -90,7 +84,9 @@ function updateLayer(deck, layer) {
90
84
  }
91
85
 
92
86
  function drawLayer(deck, map, layer) {
93
- var currentViewport = deck.props.userData.currentViewport;
87
+ let {
88
+ currentViewport
89
+ } = deck.props.userData;
94
90
 
95
91
  if (!currentViewport) {
96
92
  currentViewport = getViewport(deck, map, true);
@@ -103,19 +99,18 @@ function drawLayer(deck, map, layer) {
103
99
 
104
100
  deck._drawLayers('mapbox-repaint', {
105
101
  viewports: [currentViewport],
106
- layerFilter: function layerFilter(_ref2) {
107
- var deckLayer = _ref2.layer;
108
- return layer.id === deckLayer.id;
109
- },
102
+ layerFilter: ({
103
+ layer: deckLayer
104
+ }) => layer.id === deckLayer.id,
110
105
  clearCanvas: false
111
106
  });
112
107
  }
113
108
 
114
109
  function getViewState(map) {
115
- var _map$getCenter = map.getCenter(),
116
- lng = _map$getCenter.lng,
117
- lat = _map$getCenter.lat;
118
-
110
+ const {
111
+ lng,
112
+ lat
113
+ } = map.getCenter();
119
114
  return {
120
115
  longitude: lng,
121
116
  latitude: lat,
@@ -126,27 +121,23 @@ function getViewState(map) {
126
121
  }
127
122
 
128
123
  function getMapboxVersion(map) {
129
- var major = 0;
130
- var minor = 0;
124
+ let major = 0;
125
+ let minor = 0;
131
126
 
132
127
  if (map.version) {
133
- var _map$version$split$sl = map.version.split('.').slice(0, 2).map(Number);
134
-
135
- var _map$version$split$sl2 = (0, _slicedToArray2.default)(_map$version$split$sl, 2);
136
-
137
- major = _map$version$split$sl2[0];
138
- minor = _map$version$split$sl2[1];
128
+ [major, minor] = map.version.split('.').slice(0, 2).map(Number);
139
129
  }
140
130
 
141
131
  return {
142
- major: major,
143
- minor: minor
132
+ major,
133
+ minor
144
134
  };
145
135
  }
146
136
 
147
- function getViewport(deck, map) {
148
- var useMapboxProjection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
149
- var mapboxVersion = deck.props.userData.mapboxVersion;
137
+ function getViewport(deck, map, useMapboxProjection = true) {
138
+ const {
139
+ mapboxVersion
140
+ } = deck.props.userData;
150
141
  return new _core.WebMercatorViewport(Object.assign({
151
142
  x: 0,
152
143
  y: 0,
@@ -161,25 +152,21 @@ function getViewport(deck, map) {
161
152
  }
162
153
 
163
154
  function afterRender(deck, map) {
164
- var _deck$props$userData = deck.props.userData,
165
- mapboxLayers = _deck$props$userData.mapboxLayers,
166
- isExternal = _deck$props$userData.isExternal;
155
+ const {
156
+ mapboxLayers,
157
+ isExternal
158
+ } = deck.props.userData;
167
159
 
168
160
  if (isExternal) {
169
- var mapboxLayerIds = Array.from(mapboxLayers, function (layer) {
170
- return layer.id;
171
- });
172
- var hasNonMapboxLayers = deck.props.layers.some(function (layer) {
173
- return !mapboxLayerIds.includes(layer.id);
174
- });
161
+ const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);
162
+ const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));
175
163
 
176
164
  if (hasNonMapboxLayers) {
177
165
  deck._drawLayers('mapbox-repaint', {
178
166
  viewports: [getViewport(deck, map, false)],
179
- layerFilter: function layerFilter(_ref3) {
180
- var layer = _ref3.layer;
181
- return !mapboxLayerIds.includes(layer.id);
182
- },
167
+ layerFilter: ({
168
+ layer
169
+ }) => !mapboxLayerIds.includes(layer.id),
183
170
  clearCanvas: false
184
171
  });
185
172
  }
@@ -202,14 +189,14 @@ function updateLayers(deck) {
202
189
  return;
203
190
  }
204
191
 
205
- var layers = [];
206
- deck.props.userData.mapboxLayers.forEach(function (deckLayer) {
207
- var LayerType = deckLayer.props.type;
208
- var layer = new LayerType(deckLayer.props);
192
+ const layers = [];
193
+ deck.props.userData.mapboxLayers.forEach(deckLayer => {
194
+ const LayerType = deckLayer.props.type;
195
+ const layer = new LayerType(deckLayer.props);
209
196
  layers.push(layer);
210
197
  });
211
198
  deck.setProps({
212
- layers: layers
199
+ layers
213
200
  });
214
201
  }
215
202
  //# sourceMappingURL=deck-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/deck-utils.js"],"names":["getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blendFunc","blendEquation","userData","isExternal","mapboxLayers","Set","setProps","Object","assign","width","height","touchAction","viewState","getViewState","Deck","on","onMapMove","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","id","clearCanvas","getCenter","lng","lat","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","major","minor","version","split","slice","Number","useMapboxProjection","WebMercatorViewport","x","y","repeat","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","needsRedraw","clearRedrawFlags","forEach","LayerType","type","push"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEO,SAASA,eAAT,OAA0C;AAAA,MAAhBC,GAAgB,QAAhBA,GAAgB;AAAA,MAAXC,EAAW,QAAXA,EAAW;AAAA,MAAPC,IAAO,QAAPA,IAAO;;AAE/C,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,MAAMC,YAAY,GAAGF,IAAI,IAAIA,IAAI,CAACG,KAAL,CAAWC,aAAxC;AAEA,MAAMC,SAAS,GAAG;AAChBC,IAAAA,eAAe,EAAE,IADD;AAEhBF,IAAAA,aAAa,EAAE,yBAAM;AACnBN,MAAAA,GAAG,CAACS,cAAJ;;AACA,UAAIL,YAAJ,EAAkB;AAGhBA,QAAAA,YAAY;AACb;AACF,KATe;AAWhBM,IAAAA,UAAU,EAAE;AACVC,MAAAA,SAAS,EAAE,IADD;AAEVC,MAAAA,SAAS,EAAE,IAFD;AAGVC,MA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;AACF;;AAGDhD,EAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoB4B,eAApB,GAAsC,IAAtC;AACD;;AAED,SAASd,SAAT,CAAmB3B,IAAnB,EAAyBF,GAAzB,EAA8B;AAC5BE,EAAAA,IAAI,CAACiB,QAAL,CAAc;AACZM,IAAAA,SAAS,EAAEC,YAAY,CAAC1B,GAAD;AADX,GAAd;AAMAE,EAAAA,IAAI,CAAC+E,WAAL,CAAiB;AAACC,IAAAA,gBAAgB,EAAE;AAAnB,GAAjB;AACD;;AAED,SAAS5C,YAAT,CAAsBpC,IAAtB,EAA4B;AAC1B,MAAIA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBC,UAAxB,EAAoC;AAClC;AACD;;AAED,MAAM8D,MAAM,GAAG,EAAf;AACA5E,EAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBE,YAApB,CAAiCkE,OAAjC,CAAyC,UAAAnC,SAAS,EAAI;AACpD,QAAMoC,SAAS,GAAGpC,SAAS,CAAC3C,KAAV,CAAgBgF,IAAlC;AACA,QAAMjD,KAAK,GAAG,IAAIgD,SAAJ,CAAcpC,SAAS,CAAC3C,KAAxB,CAAd;AACAyE,IAAAA,MAAM,CAACQ,IAAP,CAAYlD,KAAZ;AACD,GAJD;AAKAlC,EAAAA,IAAI,CAACiB,QAAL,CAAc;AAAC2D,IAAAA,MAAM,EAANA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport} from '@deck.gl/core';\n\nexport function getDeckInstance({map, gl, deck}) {\n // Only create one deck instance per context\n if (map.__deck) {\n return map.__deck;\n }\n\n const customRender = deck && deck.props._customRender;\n\n const deckProps = {\n useDevicePixels: true,\n _customRender: () => {\n map.triggerRepaint();\n if (customRender) {\n // customRender may be subscribed by DeckGL React component to update child props\n // make sure it is still called\n customRender();\n }\n },\n // TODO: import these defaults from a single source of truth\n parameters: {\n depthMask: true,\n depthTest: true,\n blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n }\n };\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n // Using external gl context - do not set css size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n deck = new Deck(deckProps);\n\n // If deck is externally provided (React use case), we use deck's viewState to\n // drive the map.\n // Otherwise (pure JS use case), we use the map's viewState to drive deck.\n map.on('move', () => onMapMove(deck, map));\n map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\n });\n }\n deck.props.userData.mapboxVersion = getMapboxVersion(map);\n map.__deck = deck;\n map.on('render', () => {\n if (deck.layerManager) afterRender(deck, map);\n });\n\n return deck;\n}\n\nexport function addLayer(deck, layer) {\n deck.props.userData.mapboxLayers.add(layer);\n updateLayers(deck);\n}\n\nexport function removeLayer(deck, layer) {\n deck.props.userData.mapboxLayers.delete(layer);\n updateLayers(deck);\n}\n\nexport function updateLayer(deck, layer) {\n updateLayers(deck);\n}\n\nexport function drawLayer(deck, map, layer) {\n let {currentViewport} = deck.props.userData;\n if (!currentViewport) {\n // This is the first layer drawn in this render cycle.\n // Generate viewport from the current map state.\n currentViewport = getViewport(deck, map, true);\n deck.props.userData.currentViewport = currentViewport;\n }\n if (!deck.layerManager) {\n return;\n }\n deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nfunction getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n longitude: lng,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch()\n };\n}\n\nfunction getMapboxVersion(map) {\n // parse mapbox version string\n let major = 0;\n let minor = 0;\n if (map.version) {\n [major, minor] = map.version\n .split('.')\n .slice(0, 2)\n .map(Number);\n }\n return {major, minor};\n}\n\nfunction getViewport(deck, map, useMapboxProjection = true) {\n const {mapboxVersion} = deck.props.userData;\n\n return new WebMercatorViewport(\n Object.assign(\n {\n x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n repeat: true\n },\n getViewState(map),\n useMapboxProjection\n ? {\n // match mapbox's projection matrix\n // A change of near plane was made in 1.3.0\n // https://github.com/mapbox/mapbox-gl-js/pull/8502\n nearZMultiplier:\n (mapboxVersion.major === 1 && mapboxVersion.minor >= 3) || mapboxVersion.major >= 2\n ? 0.02\n : 1 / (deck.height || 1)\n }\n : {\n // use deck.gl's own default\n nearZMultiplier: 0.1\n }\n )\n );\n}\n\nfunction afterRender(deck, map) {\n const {mapboxLayers, isExternal} = deck.props.userData;\n\n if (isExternal) {\n // Draw non-Mapbox layers\n const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);\n const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));\n if (hasNonMapboxLayers) {\n deck._drawLayers('mapbox-repaint', {\n viewports: [getViewport(deck, map, false)],\n layerFilter: ({layer}) => !mapboxLayerIds.includes(layer.id),\n clearCanvas: false\n });\n }\n }\n\n // End of render cycle, clear generated viewport\n deck.props.userData.currentViewport = null;\n}\n\nfunction onMapMove(deck, map) {\n deck.setProps({\n viewState: getViewState(map)\n });\n // Camera changed, will trigger a map repaint right after this\n // Clear any change flag triggered by setting viewState so that deck does not request\n // a second repaint\n deck.needsRedraw({clearRedrawFlags: true});\n}\n\nfunction updateLayers(deck) {\n if (deck.props.userData.isExternal) {\n return;\n }\n\n const layers = [];\n deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
1
+ {"version":3,"sources":["../../src/deck-utils.js"],"names":["getDeckInstance","map","gl","deck","__deck","customRender","props","_customRender","deckProps","useDevicePixels","triggerRepaint","parameters","depthMask","depthTest","blendFunc","blendEquation","userData","isExternal","mapboxLayers","Set","setProps","Object","assign","width","height","touchAction","viewState","getViewState","Deck","on","onMapMove","finalize","mapboxVersion","getMapboxVersion","layerManager","afterRender","addLayer","layer","add","updateLayers","removeLayer","delete","updateLayer","drawLayer","currentViewport","getViewport","_drawLayers","viewports","layerFilter","deckLayer","id","clearCanvas","lng","lat","getCenter","longitude","latitude","zoom","getZoom","bearing","getBearing","pitch","getPitch","major","minor","version","split","slice","Number","useMapboxProjection","WebMercatorViewport","x","y","repeat","nearZMultiplier","mapboxLayerIds","Array","from","hasNonMapboxLayers","layers","some","includes","needsRedraw","clearRedrawFlags","forEach","LayerType","type","push"],"mappings":";;;;;;;;;;;AAAA;;AAEO,SAASA,eAAT,CAAyB;AAACC,EAAAA,GAAD;AAAMC,EAAAA,EAAN;AAAUC,EAAAA;AAAV,CAAzB,EAA0C;AAE/C,MAAIF,GAAG,CAACG,MAAR,EAAgB;AACd,WAAOH,GAAG,CAACG,MAAX;AACD;;AAED,QAAMC,YAAY,GAAGF,IAAI,IAAIA,IAAI,CAACG,KAAL,CAAWC,aAAxC;AAEA,QAAMC,SAAS,GAAG;AAChBC,IAAAA,eAAe,EAAE,IADD;AAEhBF,IAAAA,aAAa,EAAE,MAAM;AACnBN,MAAAA,GAAG,CAACS,cAAJ;;AACA,UAAIL,YAAJ,EAAkB;AAGhBA,QAAAA,YAAY;AACb;AACF,KATe;AAWhBM,IAAAA,UAAU,EAAE;AACVC,MAAAA,SAAS,EAAE,IADD;AAEVC,MAAAA,SAAS,EAAE,IAFD;AAGVC,MAAAA,SAAS,EAAE,kBAHD;AAIVC,MAAAA,aAAa;AAJH,KAXI;AAiBhBC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,UAAU,EAAE,KADJ;AAERC,MAAAA,YAAY,EAAE,IAAIC,GAAJ;AAFN;AAjBM,GAAlB;;AAuBA,MAAIhB,IAAJ,EAAU;AACRA,IAAAA,IAAI,CAACiB,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U,QAAX,CAAoBC,UAAxB,EAAoC;AAClC;AACD;;AAED,QAAM8D,MAAM,GAAG,EAAf;AACA5E,EAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBE,YAApB,CAAiCkE,OAAjC,CAAyCnC,SAAS,IAAI;AACpD,UAAMoC,SAAS,GAAGpC,SAAS,CAAC3C,KAAV,CAAgBgF,IAAlC;AACA,UAAMjD,KAAK,GAAG,IAAIgD,SAAJ,CAAcpC,SAAS,CAAC3C,KAAxB,CAAd;AACAyE,IAAAA,MAAM,CAACQ,IAAP,CAAYlD,KAAZ;AACD,GAJD;AAKAlC,EAAAA,IAAI,CAACiB,QAAL,CAAc;AAAC2D,IAAAA;AAAD,GAAd;AACD","sourcesContent":["import {Deck, WebMercatorViewport} from '@deck.gl/core';\n\nexport function getDeckInstance({map, gl, deck}) {\n // Only create one deck instance per context\n if (map.__deck) {\n return map.__deck;\n }\n\n const customRender = deck && deck.props._customRender;\n\n const deckProps = {\n useDevicePixels: true,\n _customRender: () => {\n map.triggerRepaint();\n if (customRender) {\n // customRender may be subscribed by DeckGL React component to update child props\n // make sure it is still called\n customRender();\n }\n },\n // TODO: import these defaults from a single source of truth\n parameters: {\n depthMask: true,\n depthTest: true,\n blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n blendEquation: gl.FUNC_ADD\n },\n userData: {\n isExternal: false,\n mapboxLayers: new Set()\n }\n };\n\n if (deck) {\n deck.setProps(deckProps);\n deck.props.userData.isExternal = true;\n } else {\n // Using external gl context - do not set css size\n Object.assign(deckProps, {\n gl,\n width: false,\n height: false,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n deck = new Deck(deckProps);\n\n // If deck is externally provided (React use case), we use deck's viewState to\n // drive the map.\n // Otherwise (pure JS use case), we use the map's viewState to drive deck.\n map.on('move', () => onMapMove(deck, map));\n map.on('remove', () => {\n deck.finalize();\n map.__deck = null;\n });\n }\n deck.props.userData.mapboxVersion = getMapboxVersion(map);\n map.__deck = deck;\n map.on('render', () => {\n if (deck.layerManager) afterRender(deck, map);\n });\n\n return deck;\n}\n\nexport function addLayer(deck, layer) {\n deck.props.userData.mapboxLayers.add(layer);\n updateLayers(deck);\n}\n\nexport function removeLayer(deck, layer) {\n deck.props.userData.mapboxLayers.delete(layer);\n updateLayers(deck);\n}\n\nexport function updateLayer(deck, layer) {\n updateLayers(deck);\n}\n\nexport function drawLayer(deck, map, layer) {\n let {currentViewport} = deck.props.userData;\n if (!currentViewport) {\n // This is the first layer drawn in this render cycle.\n // Generate viewport from the current map state.\n currentViewport = getViewport(deck, map, true);\n deck.props.userData.currentViewport = currentViewport;\n }\n if (!deck.layerManager) {\n return;\n }\n deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({layer: deckLayer}) => layer.id === deckLayer.id,\n clearCanvas: false\n });\n}\n\nfunction getViewState(map) {\n const {lng, lat} = map.getCenter();\n return {\n longitude: lng,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch()\n };\n}\n\nfunction getMapboxVersion(map) {\n // parse mapbox version string\n let major = 0;\n let minor = 0;\n if (map.version) {\n [major, minor] = map.version\n .split('.')\n .slice(0, 2)\n .map(Number);\n }\n return {major, minor};\n}\n\nfunction getViewport(deck, map, useMapboxProjection = true) {\n const {mapboxVersion} = deck.props.userData;\n\n return new WebMercatorViewport(\n Object.assign(\n {\n x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n repeat: true\n },\n getViewState(map),\n useMapboxProjection\n ? {\n // match mapbox's projection matrix\n // A change of near plane was made in 1.3.0\n // https://github.com/mapbox/mapbox-gl-js/pull/8502\n nearZMultiplier:\n (mapboxVersion.major === 1 && mapboxVersion.minor >= 3) || mapboxVersion.major >= 2\n ? 0.02\n : 1 / (deck.height || 1)\n }\n : {\n // use deck.gl's own default\n nearZMultiplier: 0.1\n }\n )\n );\n}\n\nfunction afterRender(deck, map) {\n const {mapboxLayers, isExternal} = deck.props.userData;\n\n if (isExternal) {\n // Draw non-Mapbox layers\n const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);\n const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));\n if (hasNonMapboxLayers) {\n deck._drawLayers('mapbox-repaint', {\n viewports: [getViewport(deck, map, false)],\n layerFilter: ({layer}) => !mapboxLayerIds.includes(layer.id),\n clearCanvas: false\n });\n }\n }\n\n // End of render cycle, clear generated viewport\n deck.props.userData.currentViewport = null;\n}\n\nfunction onMapMove(deck, map) {\n deck.setProps({\n viewState: getViewState(map)\n });\n // Camera changed, will trigger a map repaint right after this\n // Clear any change flag triggered by setting viewState so that deck does not request\n // a second repaint\n deck.needsRedraw({clearRedrawFlags: true});\n}\n\nfunction updateLayers(deck) {\n if (deck.props.userData.isExternal) {\n return;\n }\n\n const layers = [];\n deck.props.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({layers});\n}\n"],"file":"deck-utils.js"}
package/dist/es5/index.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "MapboxLayer", {
9
9
  enumerable: true,
10
- get: function get() {
10
+ get: function () {
11
11
  return _mapboxLayer.default;
12
12
  }
13
13
  });
@@ -1,22 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = void 0;
9
7
 
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
8
  var _deckUtils = require("./deck-utils");
15
9
 
16
- var MapboxLayer = function () {
17
- function MapboxLayer(props) {
18
- (0, _classCallCheck2.default)(this, MapboxLayer);
19
-
10
+ class MapboxLayer {
11
+ constructor(props) {
20
12
  if (!props.id) {
21
13
  throw new Error('Layer must have an unique id');
22
14
  }
@@ -29,41 +21,35 @@ var MapboxLayer = function () {
29
21
  this.props = props;
30
22
  }
31
23
 
32
- (0, _createClass2.default)(MapboxLayer, [{
33
- key: "onAdd",
34
- value: function onAdd(map, gl) {
35
- this.map = map;
36
- this.deck = (0, _deckUtils.getDeckInstance)({
37
- map: map,
38
- gl: gl,
39
- deck: this.props.deck
40
- });
41
- (0, _deckUtils.addLayer)(this.deck, this);
42
- }
43
- }, {
44
- key: "onRemove",
45
- value: function onRemove() {
46
- (0, _deckUtils.removeLayer)(this.deck, this);
47
- }
48
- }, {
49
- key: "setProps",
50
- value: function setProps(props) {
51
- Object.assign(this.props, props, {
52
- id: this.id
53
- });
24
+ onAdd(map, gl) {
25
+ this.map = map;
26
+ this.deck = (0, _deckUtils.getDeckInstance)({
27
+ map,
28
+ gl,
29
+ deck: this.props.deck
30
+ });
31
+ (0, _deckUtils.addLayer)(this.deck, this);
32
+ }
54
33
 
55
- if (this.deck) {
56
- (0, _deckUtils.updateLayer)(this.deck, this);
57
- }
58
- }
59
- }, {
60
- key: "render",
61
- value: function render(gl, matrix) {
62
- (0, _deckUtils.drawLayer)(this.deck, this.map, this);
34
+ onRemove() {
35
+ (0, _deckUtils.removeLayer)(this.deck, this);
36
+ }
37
+
38
+ setProps(props) {
39
+ Object.assign(this.props, props, {
40
+ id: this.id
41
+ });
42
+
43
+ if (this.deck) {
44
+ (0, _deckUtils.updateLayer)(this.deck, this);
63
45
  }
64
- }]);
65
- return MapboxLayer;
66
- }();
46
+ }
47
+
48
+ render(gl, matrix) {
49
+ (0, _deckUtils.drawLayer)(this.deck, this.map, this);
50
+ }
51
+
52
+ }
67
53
 
68
54
  exports.default = MapboxLayer;
69
55
  //# sourceMappingURL=mapbox-layer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mapbox-layer.js"],"names":["MapboxLayer","props","id","Error","type","renderingMode","map","deck","gl","Object","assign","matrix"],"mappings":";;;;;;;;;;;;;AAAA;;IAEqBA,W;AAEnB,uBAAYC,KAAZ,EAAmB;AAAA;;AACjB,QAAI,CAACA,KAAK,CAACC,EAAX,EAAe;AACb,YAAM,IAAIC,KAAJ,CAAU,8BAAV,CAAN;AACD;;AAED,SAAKD,EAAL,GAAUD,KAAK,CAACC,EAAhB;AACA,SAAKE,IAAL,GAAY,QAAZ;AACA,SAAKC,aAAL,GAAqBJ,KAAK,CAACI,aAAN,IAAuB,IAA5C;AACA,SAAKC,GAAL,GAAW,IAAX;AACA,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKN,KAAL,GAAaA,KAAb;AACD;;;;0BAIKK,G,EAAKE,E,EAAI;AACb,WAAKF,GAAL,GAAWA,GAAX;AACA,WAAKC,IAAL,GAAY,gCAAgB;AAACD,QAAAA,GAAG,EAAHA,GAAD;AAAME,QAAAA,EAAE,EAAFA,EAAN;AAAUD,QAAAA,IAAI,EAAE,KAAKN,KAAL,CAAWM;AAA3B,OAAhB,CAAZ;AACA,+BAAS,KAAKA,IAAd,EAAoB,IAApB;AACD;;;+BAEU;AACT,kCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;;;6BAEQN,K,EAAO;AAEdQ,MAAAA,MAAM,CAACC,MAAP,CAAc,KAAKT,KAAnB,EAA0BA,KAA1B,EAAiC;AAACC,QAAAA,EAAE,EAAE,KAAKA;AAAV,OAAjC;;AAEA,UAAI,KAAKK,IAAT,EAAe;AACb,oCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;AACF;;;2BAEMC,E,EAAIG,M,EAAQ;AACjB,gCAAU,KAAKJ,IAAf,EAAqB,KAAKD,GAA1B,EAA+B,IAA/B;AACD","sourcesContent":["import {getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer} from './deck-utils';\n\nexport default class MapboxLayer {\n /* eslint-disable no-this-before-super */\n constructor(props) {\n if (!props.id) {\n throw new Error('Layer must have an unique id');\n }\n\n this.id = props.id;\n this.type = 'custom';\n this.renderingMode = props.renderingMode || '3d';\n this.map = null;\n this.deck = null;\n this.props = props;\n }\n\n /* Mapbox custom layer methods */\n\n onAdd(map, gl) {\n this.map = map;\n this.deck = getDeckInstance({map, gl, deck: this.props.deck});\n addLayer(this.deck, this);\n }\n\n onRemove() {\n removeLayer(this.deck, this);\n }\n\n setProps(props) {\n // id cannot be changed\n Object.assign(this.props, props, {id: this.id});\n // safe guard in case setProps is called before onAdd\n if (this.deck) {\n updateLayer(this.deck, this);\n }\n }\n\n render(gl, matrix) {\n drawLayer(this.deck, this.map, this);\n }\n}\n"],"file":"mapbox-layer.js"}
1
+ {"version":3,"sources":["../../src/mapbox-layer.js"],"names":["MapboxLayer","constructor","props","id","Error","type","renderingMode","map","deck","onAdd","gl","onRemove","setProps","Object","assign","render","matrix"],"mappings":";;;;;;;AAAA;;AAEe,MAAMA,WAAN,CAAkB;AAE/BC,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,QAAI,CAACA,KAAK,CAACC,EAAX,EAAe;AACb,YAAM,IAAIC,KAAJ,CAAU,8BAAV,CAAN;AACD;;AAED,SAAKD,EAAL,GAAUD,KAAK,CAACC,EAAhB;AACA,SAAKE,IAAL,GAAY,QAAZ;AACA,SAAKC,aAAL,GAAqBJ,KAAK,CAACI,aAAN,IAAuB,IAA5C;AACA,SAAKC,GAAL,GAAW,IAAX;AACA,SAAKC,IAAL,GAAY,IAAZ;AACA,SAAKN,KAAL,GAAaA,KAAb;AACD;;AAIDO,EAAAA,KAAK,CAACF,GAAD,EAAMG,EAAN,EAAU;AACb,SAAKH,GAAL,GAAWA,GAAX;AACA,SAAKC,IAAL,GAAY,gCAAgB;AAACD,MAAAA,GAAD;AAAMG,MAAAA,EAAN;AAAUF,MAAAA,IAAI,EAAE,KAAKN,KAAL,CAAWM;AAA3B,KAAhB,CAAZ;AACA,6BAAS,KAAKA,IAAd,EAAoB,IAApB;AACD;;AAEDG,EAAAA,QAAQ,GAAG;AACT,gCAAY,KAAKH,IAAjB,EAAuB,IAAvB;AACD;;AAEDI,EAAAA,QAAQ,CAACV,KAAD,EAAQ;AAEdW,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAKZ,KAAnB,EAA0BA,KAA1B,EAAiC;AAACC,MAAAA,EAAE,EAAE,KAAKA;AAAV,KAAjC;;AAEA,QAAI,KAAKK,IAAT,EAAe;AACb,kCAAY,KAAKA,IAAjB,EAAuB,IAAvB;AACD;AACF;;AAEDO,EAAAA,MAAM,CAACL,EAAD,EAAKM,MAAL,EAAa;AACjB,8BAAU,KAAKR,IAAf,EAAqB,KAAKD,GAA1B,EAA+B,IAA/B;AACD;;AAtC8B","sourcesContent":["import {getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer} from './deck-utils';\n\nexport default class MapboxLayer {\n /* eslint-disable no-this-before-super */\n constructor(props) {\n if (!props.id) {\n throw new Error('Layer must have an unique id');\n }\n\n this.id = props.id;\n this.type = 'custom';\n this.renderingMode = props.renderingMode || '3d';\n this.map = null;\n this.deck = null;\n this.props = props;\n }\n\n /* Mapbox custom layer methods */\n\n onAdd(map, gl) {\n this.map = map;\n this.deck = getDeckInstance({map, gl, deck: this.props.deck});\n addLayer(this.deck, this);\n }\n\n onRemove() {\n removeLayer(this.deck, this);\n }\n\n setProps(props) {\n // id cannot be changed\n Object.assign(this.props, props, {id: this.id});\n // safe guard in case setProps is called before onAdd\n if (this.deck) {\n updateLayer(this.deck, this);\n }\n }\n\n render(gl, matrix) {\n drawLayer(this.deck, this.map, this);\n }\n}\n"],"file":"mapbox-layer.js"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/mapbox",
3
3
  "description": "Use deck.gl layers as custom mapbox-gl-js layers",
4
4
  "license": "MIT",
5
- "version": "8.6.0-beta.1",
5
+ "version": "8.6.3",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -31,5 +31,5 @@
31
31
  "peerDependencies": {
32
32
  "@deck.gl/core": "^8.0.0"
33
33
  },
34
- "gitHead": "ce689d7ceb9a732d8b83d959581147b36f416d38"
34
+ "gitHead": "938ee03697eecbaced24c9df637d53ab42375df1"
35
35
  }