UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

58 lines (56 loc) 9.35 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _lodash = _interopRequireDefault(require("lodash.get")); var _constants = require("@kepler.gl/constants"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project // TODO: this should be turned into a custom hook /** * A wrapper component in modals contain a image preview of the map with cloud providers * It sets export image size based on provider thumbnail size * @type {React.FunctionComponent<ImageModalContainerProps>} */ var ImageModalContainer = function ImageModalContainer(_ref) { var onUpdateImageSetting = _ref.onUpdateImageSetting, cleanupExportImage = _ref.cleanupExportImage, provider = _ref.provider, children = _ref.children; (0, _react.useEffect)(function () { onUpdateImageSetting({ exporting: true }); return function () { cleanupExportImage(); }; }, [onUpdateImageSetting, cleanupExportImage]); (0, _react.useEffect)(function () { if (provider) { if (provider.thumbnail) { onUpdateImageSetting({ mapW: (0, _lodash["default"])(provider, ['thumbnail', 'width']) || _constants.MAP_THUMBNAIL_DIMENSION.width, mapH: (0, _lodash["default"])(provider, ['thumbnail', 'height']) || _constants.MAP_THUMBNAIL_DIMENSION.height, ratio: _constants.EXPORT_IMG_RATIOS.CUSTOM, legend: false }); } } else { onUpdateImageSetting({ mapW: _constants.MAP_THUMBNAIL_DIMENSION.width, mapH: _constants.MAP_THUMBNAIL_DIMENSION.height, ratio: _constants.EXPORT_IMG_RATIOS.CUSTOM, legend: false }); } }, [provider, onUpdateImageSetting]); return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children); }; var _default = exports["default"] = ImageModalContainer; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfbG9kYXNoIiwiX2ludGVyb3BSZXF1aXJlRGVmYXVsdCIsIl9jb25zdGFudHMiLCJfZ2V0UmVxdWlyZVdpbGRjYXJkQ2FjaGUiLCJlIiwiV2Vha01hcCIsInIiLCJ0IiwiX19lc01vZHVsZSIsIl90eXBlb2YiLCJoYXMiLCJnZXQiLCJuIiwiX19wcm90b19fIiwiYSIsIk9iamVjdCIsImRlZmluZVByb3BlcnR5IiwiZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yIiwidSIsImhhc093blByb3BlcnR5IiwiY2FsbCIsImkiLCJzZXQiLCJJbWFnZU1vZGFsQ29udGFpbmVyIiwiX3JlZiIsIm9uVXBkYXRlSW1hZ2VTZXR0aW5nIiwiY2xlYW51cEV4cG9ydEltYWdlIiwicHJvdmlkZXIiLCJjaGlsZHJlbiIsInVzZUVmZmVjdCIsImV4cG9ydGluZyIsInRodW1ibmFpbCIsIm1hcFciLCJNQVBfVEhVTUJOQUlMX0RJTUVOU0lPTiIsIndpZHRoIiwibWFwSCIsImhlaWdodCIsInJhdGlvIiwiRVhQT1JUX0lNR19SQVRJT1MiLCJDVVNUT00iLCJsZWdlbmQiLCJjcmVhdGVFbGVtZW50IiwiRnJhZ21lbnQiLCJfZGVmYXVsdCIsImV4cG9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