Stylize popup

dev
Platon Yasev 4 years ago
parent 79977c00bc
commit 8e39939ef2

@ -90,6 +90,7 @@ export const MapComponent = () => {
longitude: 37.6173, longitude: 37.6173,
zoom: 9, zoom: 9,
}} }}
dragRotate={false}
ref={mapRef} ref={mapRef}
interactiveLayerIds={[pointLayer.id, "grid3", "grid4", "grid5"]} interactiveLayerIds={[pointLayer.id, "grid3", "grid4", "grid5"]}
onClick={handleClick} onClick={handleClick}

@ -1,6 +1,36 @@
import { Popup } from "react-map-gl"; 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 }) => { 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 ( return (
<Popup <Popup
longitude={lng} longitude={lng}
@ -9,8 +39,21 @@ export const MapPopup = ({ feature, lat, lng, onClose }) => {
onClose={onClose} onClose={onClose}
closeOnClick={false} closeOnClick={false}
> >
<div style={{ color: "red", fontWeight: "bold" }}> <div className={"min-w-[200px]"}>
<pre>{JSON.stringify(feature.properties, null, 2)}</pre> {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> </div>
</Popup> </Popup>
); );

@ -8,7 +8,7 @@ const pointColors = {
kiosk: "#112cda", kiosk: "#112cda",
mfc: "#932301", mfc: "#932301",
library: "#a51eda", library: "#a51eda",
dk: "#e7dd24", dk: "#ff5204",
sport: "#138c44", sport: "#138c44",
}; };
@ -35,8 +35,9 @@ export const pointLayer = {
"black", "black",
], ],
"circle-radius": 4, "circle-radius": 4,
"circle-stroke-width": 1, "circle-stroke-width": 0.4,
"circle-stroke-color": "#fff", "circle-stroke-color": "#fff",
"circle-opacity": 0.8,
}, },
}; };

@ -0,0 +1,7 @@
export const TYPE_MAPPER = {
kiosk: "Городской киоск",
mfc: "МФЦ",
library: "Библиотека",
dk: "Дом культуры и отдыха",
sport: "Спортивный объект",
};

@ -4,12 +4,12 @@
.mapboxgl-popup-content, .mapboxgl-popup-content,
.maplibregl-popup-content { .maplibregl-popup-content {
@apply bg-white-background shadow-lg rounded-md; @apply bg-grey-light shadow-lg rounded-md;
} }
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip, .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip,
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
@apply border-t-white-background; @apply border-t-grey-light;
} }
.ant-popover-inner { .ant-popover-inner {

@ -8,7 +8,7 @@ export const RatingSlider = () => {
return ( return (
<Slider <Slider
title={"Востребованность постамата, усл. ед."} title={"Востребованность постамата, у.e."}
value={rate} value={rate}
onAfterChange={handleAfterChange} onAfterChange={handleAfterChange}
max={10} max={10}

@ -10,7 +10,7 @@ import { Settings } from "./Settings";
export const Sidebar = () => { export const Sidebar = () => {
return ( return (
<div className="absolute top-10 right-10 bg-white-background w-[300px] rounded-xl p-3"> <div className="absolute top-[10px] right-[10px] bg-white-background w-[300px] rounded-xl p-3">
<Popover <Popover
placement="leftTop" placement="leftTop"
title={"Веса факторов"} title={"Веса факторов"}

@ -5,9 +5,11 @@ module.exports = {
extend: { extend: {
colors: { colors: {
primary: "#CC2222FF", primary: "#CC2222FF",
'primary-light': "#ffc6c6",
blue: "rgba(167,201,236,0.57)", blue: "rgba(167,201,236,0.57)",
"white-background": "rgba(255, 255, 255, 0.9)", "white-background": "rgba(255, 255, 255, 0.9)",
grey: "rgba(0,0, 0, 0.5)", grey: "rgba(0,0, 0, 0.5)",
"grey-light": "rgba(239,239,239,0.9)",
}, },
}, },
}, },

Loading…
Cancel
Save