kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
80 lines (78 loc) • 12.8 kB
JavaScript
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _cloudHeader = _interopRequireDefault(require("./cloud-components/cloud-header"));
var _cloudMaps = require("./cloud-components/cloud-maps");
var _useCloudListProvider2 = require("../hooks/use-cloud-list-provider");
var _providerSelect = require("./cloud-components/provider-select");
var _flexContainer = require("../common/flex-container");
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
LoadStorageMapFactory.deps = [_cloudHeader["default"]];
function LoadStorageMapFactory(CloudHeader) {
var LoadStorageMap = function LoadStorageMap(_ref) {
var onLoadCloudMap = _ref.onLoadCloudMap;
var _useCloudListProvider = (0, _useCloudListProvider2.useCloudListProvider)(),
currentProvider = _useCloudListProvider.provider,
setProvider = _useCloudListProvider.setProvider,
cloudProviders = _useCloudListProvider.cloudProviders;
var _useState = (0, _react.useState)(false),
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
isLoading = _useState2[0],
setIsLoading = _useState2[1];
var _useState3 = (0, _react.useState)(null),
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
maps = _useState4[0],
setMaps = _useState4[1];
var _useState5 = (0, _react.useState)(null),
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
error = _useState6[0],
setError = _useState6[1];
var setProviderInfo = (0, _react.useCallback)(function (provider) {
setMaps(null);
setError(null);
if (provider) {
setIsLoading(true);
provider.listMaps().then(setMaps)["catch"](setError)["finally"](function () {
return setIsLoading(false);
});
} else {
setIsLoading(false);
}
}, []);
(0, _react.useEffect)(function () {
setProviderInfo(currentProvider);
}, [currentProvider, setProviderInfo]);
var onSelectMap = (0, _react.useCallback)(function (provider, map) {
onLoadCloudMap({
loadParams: map.loadParams,
provider: provider
});
}, [onLoadCloudMap]);
return /*#__PURE__*/_react["default"].createElement(_flexContainer.FlexColContainer, null, !currentProvider ? /*#__PURE__*/_react["default"].createElement(_providerSelect.ProviderSelect, {
cloudProviders: cloudProviders
}) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(CloudHeader, {
provider: currentProvider,
onBack: function onBack() {
return setProvider(null);
}
}), /*#__PURE__*/_react["default"].createElement(_cloudMaps.CloudMaps, {
isLoading: isLoading,
onSelectMap: onSelectMap,
provider: currentProvider,
error: error,
maps: maps
})));
};
return LoadStorageMap;
}
var _default = exports["default"] = LoadStorageMapFactory;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfY2xvdWRIZWFkZXIiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwiX2Nsb3VkTWFwcyIsIl91c2VDbG91ZExpc3RQcm92aWRlcjIiLCJfcHJvdmlkZXJTZWxlY3QiLCJfZmxleENvbnRhaW5lciIsIl9nZXRSZXF1aX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AgICAgbG9hZFBhcmFtczogbWFwLmxvYWRQYXJhbXMsXG4gICAgICAgICAgcHJvdmlkZXJcbiAgICAgICAgfSk7XG4gICAgICB9LFxuICAgICAgW29uTG9hZENsb3VkTWFwXVxuICAgICk7XG5cbiAgICByZXR1cm4gKFxuICAgICAgPEZsZXhDb2xDb250YWluZXI+XG4gICAgICAgIHshY3VycmVudFByb3ZpZGVyID8gKFxuICAgICAgICAgIDxQcm92aWRlclNlbGVjdCBjbG91ZFByb3ZpZGVycz17Y2xvdWRQcm92aWRlcnN9IC8+XG4gICAgICAgICkgOiAoXG4gICAgICAgICAgPD5cbiAgICAgICAgICAgIDxDbG91ZEhlYWRlciBwcm92aWRlcj17Y3VycmVudFByb3ZpZGVyfSBvbkJhY2s9eygpID0+IHNldFByb3ZpZGVyKG51bGwpfSAvPlxuICAgICAgICAgICAgPENsb3VkTWFwc1xuICAgICAgICAgICAgICBpc0xvYWRpbmc9e2lzTG9hZGluZ31cbiAgICAgICAgICAgICAgb25TZWxlY3RNYXA9e29uU2VsZWN0TWFwfVxuICAgICAgICAgICAgICBwcm92aWRlcj17Y3VycmVudFByb3ZpZGVyfVxuICAgICAgICAgICAgICBlcnJvcj17ZXJyb3J9XG4gICAgICAgICAgICAgIG1hcHM9e21hcHN9XG4gICAgICAgICAgICAvPlxuICAgICAgICAgIDwvPlxuICAgICAgICApfVxuICAgICAgPC9GbGV4Q29sQ29udGFpbmVyPlxuICAgICk7XG4gIH07XG5cbiAgcmV0dXJuIExvYWRTdG9yYWdlTWFwO1xufVxuXG5leHBvcnQgZGVmYXVsdCBMb2FkU3RvcmFnZU1hcEZhY3Rvcnk7XG4iXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUdBLElBQUFBLE1BQUEsR0FBQUMsdUJBQUEsQ0FBQUMsT0FBQTtBQUNBLElBQUFDLFlBQUEsR0FBQUMsc0JBQUEsQ0FBQUYsT0FBQTtBQUNBLElBQUFHLFVBQUEsR0FBQUgsT0FBQTtBQU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