kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
152 lines (126 loc) • 16.4 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.StyledLayerName = void 0;
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _styledComponents2 = require("../common/styled-components");
var _icons = require("../common/icons");
var _propTypes = _interopRequireDefault(require("prop-types"));
var _dataUtils = require("../../utils/data-utils");
function _templateObject() {
var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-size: 12px;\n letter-spacing: 0.43px;\n text-transform: capitalize;\n padding: 0 14px;\n margin-top: 12px;\n\n svg {\n margin-right: 4px;\n }\n"]);
_templateObject = function _templateObject() {
return data;
};
return data;
}
var StyledLayerName = (0, _styledComponents["default"])(_styledComponents2.CenterFlexbox)(_templateObject(), function (props) {
return props.theme.textColorHl;
});
exports.StyledLayerName = StyledLayerName;
var Row = function Row(_ref) {
var name = _ref.name,
value = _ref.value,
url = _ref.url;
// Set 'url' to 'value' if it looks like a url
if (!url && value && typeof value === 'string' && value.match(/^http/)) {
url = value;
}
var asImg = /<img>/.test(name);
return _react["default"].createElement("tr", {
className: "row",
key: name
}, _react["default"].createElement("td", {
className: "row__name"
}, name), _react["default"].createElement("td", {
className: "row__value"
}, asImg ? _react["default"].createElement("img", {
src: value
}) : url ? _react["default"].createElement("a", {
target: "_blank",
rel: "noopener noreferrer",
href: url
}, value) : value));
};
var EntryInfo = function EntryInfo(_ref2) {
var fieldsToShow = _ref2.fieldsToShow,
fields = _ref2.fields,
data = _ref2.data;
return _react["default"].createElement("tbody", null, fieldsToShow.map(function (name) {
return _react["default"].createElement(EntryInfoRow, {
key: name,
name: name,
fields: fields,
data: data
});
}));
};
var EntryInfoRow = function EntryInfoRow(_ref3) {
var name = _ref3.name,
fields = _ref3.fields,
data = _ref3.data;
var field = fields.find(function (f) {
return f.name === name;
});
if (!field) {
return null;
}
var valueIdx = field.tableFieldIndex - 1;
var displayValue = (0, _dataUtils.parseFieldValue)(data[valueIdx], field.type);
return _react["default"].createElement(Row, {
name: name,
value: displayValue
});
};
var CellInfo = function CellInfo(_ref4) {
var data = _ref4.data,
layer = _ref4.layer;
var _layer$config = layer.config,
colorField = _layer$config.colorField,
sizeField = _layer$config.sizeField;
return _react["default"].createElement("tbody", null, _react["default"].createElement(Row, {
name: 'total points',
key: "count",
value: data.points && data.points.length
}), colorField && layer.visualChannels.color ? _react["default"].createElement(Row, {
name: layer.getVisualChannelDescription('color').measure,
key: "color",
value: data.colorValue || 'N/A'
}) : null, sizeField && layer.visualChannels.size ? _react["default"].createElement(Row, {
name: layer.getVisualChannelDescription('size').measure,
key: "size",
value: data.elevationValue || 'N/A'
}) : null);
};
var LayerHoverInfoFactory = function LayerHoverInfoFactory() {
var LayerHoverInfo = function LayerHoverInfo(props) {
var data = props.data,
layer = props.layer;
if (!data || !layer) {
return null;
}
return _react["default"].createElement("div", {
className: "map-popover__layer-info"
}, _react["default"].createElement(StyledLayerName, {
className: "map-popover__layer-name"
}, _react["default"].createElement(_icons.Layers, {
height: "12px"
}), props.layer.config.label), _react["default"].createElement("table", {
className: "map-popover__table"
}, props.layer.isAggregated ? _react["default"].createElement(CellInfo, props) : _react["default"].createElement(EntryInfo, props)));
};
LayerHoverInfo.propTypes = {
fields: _propTypes["default"].arrayOf(_propTypes["default"].any),
fieldsToShow: _propTypes["default"].arrayOf(_propTypes["default"].any),
layer: _propTypes["default"].object,
data: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].any), _propTypes["default"].object])
};
return LayerHoverInfo;
};
var _default = LayerHoverInfoFactory;
exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL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