Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Bug] fix image export doesnt get called when map rendered (#494)
Shan He89f549cf28c3
diff --git a/src/components/map-container.js b/src/components/map-container.jsindex 83f1d25f8..575f9923c 100644--- a/src/components/map-container.js+++ b/src/components/map-container.js@@ -159,13 +159,14 @@ export default function MapContainerFactory(MapPopover, MapControl) {this._map = mapbox.getMap();// i noticed in certain context we don't access the actual map element- if (!this.map) {+ if (!this._map) {return;}// bind mapboxgl event listenerthis._map.on(MAPBOXGL_STYLE_UPDATE, this._onMapboxStyleUpdate);this._map.on(MAPBOXGL_RENDER, () => {+if (typeof this.props.onMapRender === 'function') {this.props.onMapRender(this._map);}diff --git a/src/utils/dom-to-image.js b/src/utils/dom-to-image.jsindex 460d49f3d..e33fe3614 100644--- a/src/utils/dom-to-image.js+++ b/src/utils/dom-to-image.js@@ -23,12 +23,7 @@* Modified by heshan0131 to allow loading external stylesheets and inline webfonts*/-import window, {- XMLHttpRequest,- FileReader,- setTimeout,- fetch-} from 'global/window';+import window from 'global/window';import document from 'global/document';import console from 'global/console';@@ -489,7 +484,7 @@ function newUtil() {}return new Promise(resolve => {- const request = new XMLHttpRequest();+ const request = new window.XMLHttpRequest();request.onreadystatechange = done;request.ontimeout = timeout;@@ -519,7 +514,7 @@ function newUtil() {return;}- const encoder = new FileReader();+ const encoder = new window.FileReader();encoder.onloadend = () => {const content = encoder.result.split(/,/)[1];resolve(content);@@ -555,7 +550,7 @@ function newUtil() {function delay(ms) {return arg => {return new Promise((resolve) => {- setTimeout(() => {+ window.setTimeout(() => {resolve(arg);}, ms);});@@ -686,7 +681,7 @@ function newFontFaces() {return Promise.all(styleSheets.map(sheet => {if (sheet.href) {- return fetch(sheet.href, {credentials: 'omit'})+ return window.fetch(sheet.href, {credentials: 'omit'}).then(toText).then(setBaseHref(sheet.href)).then(toStyleSheet)