@deck.gl/mapbox 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.
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -9,21 +11,23 @@ exports.removeLayer = removeLayer;
9
11
  exports.updateLayer = updateLayer;
10
12
  exports.drawLayer = drawLayer;
11
13
 
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
12
16
  var _core = require("@deck.gl/core");
13
17
 
14
- function getDeckInstance({
15
- map,
16
- gl,
17
- deck
18
- }) {
18
+ function getDeckInstance(_ref) {
19
+ var map = _ref.map,
20
+ gl = _ref.gl,
21
+ deck = _ref.deck;
22
+
19
23
  if (map.__deck) {
20
24
  return map.__deck;
21
25
  }
22
26
 
23
- const customRender = deck && deck.props._customRender;
24
- const deckProps = {
27
+ var customRender = deck && deck.props._customRender;
28
+ var deckProps = {
25
29
  useDevicePixels: true,
26
- _customRender: () => {
30
+ _customRender: function _customRender() {
27
31
  map.triggerRepaint();
28
32
 
29
33
  if (customRender) {
@@ -47,15 +51,17 @@ function getDeckInstance({
47
51
  deck.props.userData.isExternal = true;
48
52
  } else {
49
53
  Object.assign(deckProps, {
50
- gl,
54
+ gl: gl,
51
55
  width: false,
52
56
  height: false,
53
57
  touchAction: 'unset',
54
58
  viewState: getViewState(map)
55
59
  });
56
60
  deck = new _core.Deck(deckProps);
57
- map.on('move', () => onMapMove(deck, map));
58
- map.on('remove', () => {
61
+ map.on('move', function () {
62
+ return onMapMove(deck, map);
63
+ });
64
+ map.on('remove', function () {
59
65
  deck.finalize();
60
66
  map.__deck = null;
61
67
  });
@@ -63,7 +69,7 @@ function getDeckInstance({
63
69
 
64
70
  deck.props.userData.mapboxVersion = getMapboxVersion(map);
65
71
  map.__deck = deck;
66
- map.on('render', () => {
72
+ map.on('render', function () {
67
73
  if (deck.layerManager) afterRender(deck, map);
68
74
  });
69
75
  return deck;
@@ -84,9 +90,7 @@ function updateLayer(deck, layer) {
84
90
  }
85
91
 
86
92
  function drawLayer(deck, map, layer) {
87
- let {
88
- currentViewport
89
- } = deck.props.userData;
93
+ var currentViewport = deck.props.userData.currentViewport;
90
94
 
91
95
  if (!currentViewport) {
92
96
  currentViewport = getViewport(deck, map, true);
@@ -99,18 +103,19 @@ function drawLayer(deck, map, layer) {
99
103
 
100
104
  deck._drawLayers('mapbox-repaint', {
101
105
  viewports: [currentViewport],
102
- layerFilter: ({
103
- layer: deckLayer
104
- }) => layer.id === deckLayer.id,
106
+ layerFilter: function layerFilter(_ref2) {
107
+ var deckLayer = _ref2.layer;
108
+ return layer.id === deckLayer.id;
109
+ },
105
110
  clearCanvas: false
106
111
  });
107
112
  }
108
113
 
109
114
  function getViewState(map) {
110
- const {
111
- lng,
112
- lat
113
- } = map.getCenter();
115
+ var _map$getCenter = map.getCenter(),
116
+ lng = _map$getCenter.lng,
117
+ lat = _map$getCenter.lat;
118
+
114
119
  return {
115
120
  longitude: lng,
116
121
  latitude: lat,
@@ -121,23 +126,27 @@ function getViewState(map) {
121
126
  }
122
127
 
123
128
  function getMapboxVersion(map) {
124
- let major = 0;
125
- let minor = 0;
129
+ var major = 0;
130
+ var minor = 0;
126
131
 
127
132
  if (map.version) {
128
- [major, minor] = map.version.split('.').slice(0, 2).map(Number);
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];
129
139
  }
130
140
 
131
141
  return {
132
- major,
133
- minor
142
+ major: major,
143
+ minor: minor
134
144
  };
135
145
  }
136
146
 
137
- function getViewport(deck, map, useMapboxProjection = true) {
138
- const {
139
- mapboxVersion
140
- } = deck.props.userData;
147
+ function getViewport(deck, map) {
148
+ var useMapboxProjection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
149
+ var mapboxVersion = deck.props.userData.mapboxVersion;
141
150
  return new _core.WebMercatorViewport(Object.assign({
142
151
  x: 0,
143
152
  y: 0,
@@ -152,21 +161,25 @@ function getViewport(deck, map, useMapboxProjection = true) {
152
161
  }
153
162
 
154
163
  function afterRender(deck, map) {
155
- const {
156
- mapboxLayers,
157
- isExternal
158
- } = deck.props.userData;
164
+ var _deck$props$userData = deck.props.userData,
165
+ mapboxLayers = _deck$props$userData.mapboxLayers,
166
+ isExternal = _deck$props$userData.isExternal;
159
167
 
160
168
  if (isExternal) {
161
- const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);
162
- const hasNonMapboxLayers = deck.props.layers.some(layer => !mapboxLayerIds.includes(layer.id));
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
+ });
163
175
 
164
176
  if (hasNonMapboxLayers) {
165
177
  deck._drawLayers('mapbox-repaint', {
166
178
  viewports: [getViewport(deck, map, false)],
167
- layerFilter: ({
168
- layer
169
- }) => !mapboxLayerIds.includes(layer.id),
179
+ layerFilter: function layerFilter(_ref3) {
180
+ var layer = _ref3.layer;
181
+ return !mapboxLayerIds.includes(layer.id);
182
+ },
170
183
  clearCanvas: false
171
184
  });
172
185
  }
@@ -189,14 +202,14 @@ function updateLayers(deck) {
189
202
  return;
190
203
  }
191
204
 
192
- const layers = [];
193
- deck.props.userData.mapboxLayers.forEach(deckLayer => {
194
- const LayerType = deckLayer.props.type;
195
- const layer = new LayerType(deckLayer.props);
205
+ var layers = [];
206
+ deck.props.userData.mapboxLayers.forEach(function (deckLayer) {
207
+ var LayerType = deckLayer.props.type;
208
+ var layer = new LayerType(deckLayer.props);
196
209
  layers.push(layer);
197
210
  });
198
211
  deck.setProps({
199
- layers
212
+ layers: layers
200
213
  });
201
214
  }
202
215
  //# 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","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,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,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,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"}
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,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,QAAL,CAAcZ,SAAd;AACAL,IAAAA,IAAI,CAACG,KAAL,CAAWU,QAAX,CAAoBC,UAApB,GAAiC,IAAjC;AACD,GAHD,MAGO;AAELI,IAAAA,MAAM,CAACC,MAAP,CAAcd,SAAd,EAAyB;AACvBN,MAAAA,EAAE,EAAFA,EADuB;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C,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"}
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 () {
10
+ get: function get() {
11
11
  return _mapboxLayer.default;
12
12
  }
13
13
  });
@@ -1,14 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
8
14
  var _deckUtils = require("./deck-utils");
9
15
 
10
- class MapboxLayer {
11
- constructor(props) {
16
+ var MapboxLayer = function () {
17
+ function MapboxLayer(props) {
18
+ (0, _classCallCheck2.default)(this, MapboxLayer);
19
+
12
20
  if (!props.id) {
13
21
  throw new Error('Layer must have an unique id');
14
22
  }
@@ -21,35 +29,41 @@ class MapboxLayer {
21
29
  this.props = props;
22
30
  }
23
31
 
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
- }
33
-
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);
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);
45
42
  }
46
- }
47
-
48
- render(gl, matrix) {
49
- (0, _deckUtils.drawLayer)(this.deck, this.map, this);
50
- }
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
+ });
51
54
 
52
- }
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);
63
+ }
64
+ }]);
65
+ return MapboxLayer;
66
+ }();
53
67
 
54
68
  exports.default = MapboxLayer;
55
69
  //# sourceMappingURL=mapbox-layer.js.map
@@ -1 +1 @@
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"}
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"}
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.4",
5
+ "version": "8.6.5",
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": "750695c9f13595fa01982d81cdc2eb11bb5593b7"
34
+ "gitHead": "62726f0bd67091a673f3dca276515199276e83bd"
35
35
  }