Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] pass set useDevicePixels to deck.gl to plot container (#663)

Shan He30460956dae5
diff --git a/src/components/plot-container.js b/src/components/plot-container.js
index 34fd299f6..79687739c 100644
--- a/src/components/plot-container.js
+++ b/src/components/plot-container.js
@@ -25,7 +25,6 @@ import {createSelector} from 'reselect';
import styled from 'styled-components';
import {StaticMap} from 'react-map-gl';
import debounce from 'lodash.debounce';
-import window from 'global/window';
import {exportImageError} from 'utils/notifications-utils';
import MapContainerFactory from './map-container';
import {calculateExportImageSize, convertToPng} from 'utils/export-image-utils';
@@ -51,7 +50,8 @@ const StyledPlotContainer = styled.div`
const deckGlProps = {
glOptions: {
- preserveDrawingBuffer: true
+ preserveDrawingBuffer: true,
+ useDevicePixels: false
}
};
@@ -100,29 +100,19 @@ export default function PlotContainerFactory(MapContainer) {
}
};
- _onRetrievingFinish = (devicePixelRatio) => {
- window.devicePixelRatio = devicePixelRatio;
- };
-
_retrieveNewScreenshot = () => {
if (this.plottingAreaRef) {
- // setting windowDevicePixelRatio to 1
- // so that large mapbox base map will load in full
- const savedDevicePixelRatio = window.devicePixelRatio;
- window.devicePixelRatio = 1;
this.props.startExportingImage();
const filter = node => node.className !== 'mapboxgl-control-container';
convertToPng(this.plottingAreaRef, {filter}).then(dataUri => {
this.props.setExportImageDataUri(dataUri);
- this._onRetrievingFinish(savedDevicePixelRatio);
})
.catch(err => {
this.props.setExportImageError(err);
this.props.addNotification(exportImageError({err}));
- this._onRetrievingFinish(savedDevicePixelRatio);
});
}
};
diff --git a/src/utils/dom-to-image.js b/src/utils/dom-to-image.js
index d0547a2af..387bbccfb 100644
--- a/src/utils/dom-to-image.js
+++ b/src/utils/dom-to-image.js
@@ -207,9 +207,6 @@ function cloneNode(node, filter, root) {
return Promise.resolve(clone);
}
- return cloneChildrenInOrder(clone, util.asArray(children))
- .then(() => clone);
-
function cloneChildrenInOrder(parent, arrChildren) {
let done = Promise.resolve();
arrChildren.forEach(child => {
@@ -221,6 +218,9 @@ function cloneNode(node, filter, root) {
});
return done;
}
+
+ return cloneChildrenInOrder(clone, util.asArray(children))
+ .then(() => clone);
}
function processClone(original, clone) {