|
|
|
|
@ -1,6 +1,36 @@
|
|
|
|
|
import { Popup } from "react-map-gl";
|
|
|
|
|
import { Col, Row } from "antd";
|
|
|
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
|
import { TYPE_MAPPER } from "../config";
|
|
|
|
|
|
|
|
|
|
const pointConfig = [
|
|
|
|
|
{
|
|
|
|
|
field: "category",
|
|
|
|
|
name: "Тип",
|
|
|
|
|
formatter: (value) => TYPE_MAPPER[value],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: "msk_ao",
|
|
|
|
|
name: "АО",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: "msk_rayon",
|
|
|
|
|
name: "Район",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const gridConfig = [
|
|
|
|
|
{
|
|
|
|
|
field: "rate",
|
|
|
|
|
name: "Востребованность, у.е.",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const MapPopup = ({ feature, lat, lng, onClose }) => {
|
|
|
|
|
const isPoint = feature.geometry.type === "Point";
|
|
|
|
|
const config = isPoint ? pointConfig : gridConfig;
|
|
|
|
|
const layout = isPoint ? [10, 14] : [20, 4];
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Popup
|
|
|
|
|
longitude={lng}
|
|
|
|
|
@ -9,8 +39,21 @@ export const MapPopup = ({ feature, lat, lng, onClose }) => {
|
|
|
|
|
onClose={onClose}
|
|
|
|
|
closeOnClick={false}
|
|
|
|
|
>
|
|
|
|
|
<div style={{ color: "red", fontWeight: "bold" }}>
|
|
|
|
|
<pre>{JSON.stringify(feature.properties, null, 2)}</pre>
|
|
|
|
|
<div className={"min-w-[200px]"}>
|
|
|
|
|
{config.map((item) => {
|
|
|
|
|
const value = feature.properties[item.field];
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Row className={twMerge("p-1")} key={item.field}>
|
|
|
|
|
<Col span={layout[0]} className={"font-semibold"}>
|
|
|
|
|
{item.name}
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={layout[1]}>
|
|
|
|
|
{item.formatter ? item.formatter(value) : value}
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</Popup>
|
|
|
|
|
);
|
|
|
|
|
|