Point.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { PureComponent } from "react";
  2. import { CustomOverlay } from "react-bmapgl";
  3. import styled from "styled-components";
  4. import img1 from "../../assets/icon1.jpg";
  5. class Project extends PureComponent {
  6. constructor(props) {
  7. super(props);
  8. this.state = { visible: false };
  9. }
  10. toggleInfo() {
  11. if (!this.props.data) return;
  12. this.setState({
  13. visible: !this.state.visible,
  14. });
  15. }
  16. render() {
  17. const { position, title, onClick } = this.props;
  18. return (
  19. <CustomOverlay position={position}>
  20. <Box>
  21. <div className="text">{title}</div>
  22. <div onClick={(e) => onClick(e)} className={`icon iconWater`}></div>
  23. </Box>
  24. </CustomOverlay>
  25. );
  26. }
  27. }
  28. const Box = styled.div`
  29. position: relative;
  30. text-align: center;
  31. .text {
  32. padding: 4px 10px;
  33. white-space: nowrap;
  34. background-color: rgba(8, 41, 75, 0.7);
  35. color: #fff;
  36. position: absolute;
  37. bottom: 120%;
  38. left: 50%;
  39. transform: translateX(-50%);
  40. max-width: 100px;
  41. }
  42. .icon {
  43. width: 30px;
  44. height: 30px;
  45. margin: auto;
  46. background-size: 100% 100%;
  47. background-position: center;
  48. background-repeat: no-repeat;
  49. }
  50. .iconWater {
  51. background-image: url(${img1});
  52. }
  53. `;
  54. export default Project;