UNPKG

kepler.gl

Version:

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

125 lines (105 loc) 11.7 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _react = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _lodash = _interopRequireDefault(require("lodash.get")); var _defaultSettings = require("../../constants/default-settings"); // Copyright (c) 2020 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. /** * 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 * @component */ var ImageModalContainer = /*#__PURE__*/ function (_Component) { (0, _inherits2["default"])(ImageModalContainer, _Component); function ImageModalContainer() { (0, _classCallCheck2["default"])(this, ImageModalContainer); return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(ImageModalContainer).apply(this, arguments)); } (0, _createClass2["default"])(ImageModalContainer, [{ key: "componentDidMount", value: function componentDidMount() { this._updateThumbSize(true); } }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { // set thumbnail size if provider changes if (this.props.currentProvider !== prevProps.currentProvider && this.props.currentProvider) { this._updateThumbSize(); } } }, { key: "_updateThumbSize", value: function _updateThumbSize(initialMount) { var _this = this; if (this.props.currentProvider && this.props.cloudProviders.length) { var provider = this.props.cloudProviders.find(function (p) { return p.name === _this.props.currentProvider; }); if (provider && provider.thumbnail) { this.props.onUpdateImageSetting({ mapW: (0, _lodash["default"])(provider, ['thumbnail', 'width']) || _defaultSettings.MAP_THUMBNAIL_DIMENSION.width, mapH: (0, _lodash["default"])(provider, ['thumbnail', 'height']) || _defaultSettings.MAP_THUMBNAIL_DIMENSION.height, ratio: _defaultSettings.EXPORT_IMG_RATIOS.CUSTOM, legend: false }); } } else if (initialMount) { this.props.onUpdateImageSetting({ mapW: _defaultSettings.MAP_THUMBNAIL_DIMENSION.width, mapH: _defaultSettings.MAP_THUMBNAIL_DIMENSION.height, ratio: _defaultSettings.EXPORT_IMG_RATIOS.CUSTOM }); } } }, { key: "render", value: function render() { return _react["default"].createElement(_react["default"].Fragment, null, this.props.children); } }]); return ImageModalContainer; }(_react.Component); exports["default"] = ImageModalContainer; (0, _defineProperty2["default"])(ImageModalContainer, "propTypes", { onUpdateImageSetting: _propTypes["default"].func.isRequired, cloudProviders: _propTypes["default"].arrayOf(_propTypes["default"].object), currentProvider: _propTypes["default"].string }); (0, _defineProperty2["default"])(ImageModalContainer, "defaultProps", {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