Renxy 2 жил өмнө
parent
commit
c1817a8ede

+ 3 - 3
src/components/Map/ArrowPolyline.js

@@ -1,7 +1,7 @@
 // 带箭头的折现
 import React, { useEffect, useRef } from "react";
 import { Polyline } from "react-bmapgl";
-import IconUrl from "../../assets/icon-arr.png";
+import IconUrl from "../../assets/arrow.png";
 const { BMapGL } = window;
 
 const ArrowPolyline = (props) => {
@@ -15,7 +15,7 @@ const ArrowPolyline = (props) => {
     });
 
     // 绘制箭头
-    for (var i = 1; i < points.length; i++) {
+    for (var i = 1; i < points.length; i = i + 4) {
       var startPoint = points[i - 1];
       var endPoint = points[i];
       var angle = getAngle(startPoint, endPoint); // 计算箭头的方向角度
@@ -51,7 +51,7 @@ const ArrowPolyline = (props) => {
         d = angle; // 如果终点在起点右边,角度不变
       }
     }
-    return d;
+    return d - 90;
   };
 
   useEffect(() => {

+ 77 - 27
src/components/Map/MockData.js

@@ -40,6 +40,29 @@ export const IconType = {
   SewageWorks: "iconWater",
 };
 
+export const pipeTipData = [
+  {
+    name: "DN800",
+    position: { lng: 116.96669547113085, lat: 36.59878897259996 },
+  },
+  {
+    name: "DN1400",
+    position: { lng: 117.01585074863684, lat: 36.62984298385826 },
+  },
+  {
+    name: "DN600",
+    position: { lng: 117.07521077673618, lat: 36.638647049017294 },
+  },
+  {
+    name: "DN500",
+    position: { lng: 117.10093824654196, lat: 36.62312340935139 },
+  },
+  {
+    name: "DN820",
+    position: { lng: 116.98408666580401, lat: 36.65474659551234 },
+  },
+];
+
 export const PipeData = [
   {
     type: ShowIconType.InPipeNet,
@@ -47,8 +70,8 @@ export const PipeData = [
     icon: IconType.PipeNet,
     data: [
       {
-        strokeColor: "red",
-        strokeWeight: 2,
+        strokeColor: "#0ab8d9",
+        strokeWeight: 1,
         fillColor: "#0ab8d9",
         fillOpacity: 0.3,
         position: [
@@ -74,9 +97,9 @@ export const PipeData = [
         ],
       },
       {
-        strokeColor: "red",
-        strokeWeight: 0.5,
-        fillColor: "#0ab8d9",
+        strokeColor: "yellow",
+        strokeWeight: 1,
+        fillColor: "yellow",
         fillOpacity: 0.3,
         position: [
           { lng: 116.94201421856121, lat: 36.59797447579483 },
@@ -94,7 +117,7 @@ export const PipeData = [
       },
       {
         strokeColor: "red",
-        strokeWeight: 2,
+        strokeWeight: 1,
         fillColor: "#0ab8d9",
         fillOpacity: 0.3,
         position: [
@@ -119,7 +142,7 @@ export const PipeData = [
       },
       {
         strokeColor: "red",
-        strokeWeight: 2,
+        strokeWeight: 1,
         fillColor: "#0ab8d9",
         fillOpacity: 0.3,
         position: [
@@ -141,7 +164,7 @@ export const PipeData = [
     data: [
       {
         strokeColor: "#66ccff",
-        strokeWeight: 2,
+        strokeWeight: 1,
         fillColor: "#0ab8d9",
         fillOpacity: 0.3,
         position: [
@@ -156,9 +179,9 @@ export const PipeData = [
         ],
       },
       {
-        strokeColor: "#66ccff",
-        strokeWeight: 2,
-        fillColor: "#0ab8d9",
+        strokeColor: "yellow",
+        strokeWeight: 1,
+        fillColor: "yellow",
         fillOpacity: 0.3,
         position: [
           { lng: 116.94988193616678, lat: 36.65670191951822 },
@@ -175,24 +198,9 @@ export const PipeData = [
           { lng: 117.16733209600235, lat: 36.67345402680362 },
         ],
       },
-      // {
-      //   strokeColor: "#66ccff",
-      //   strokeWeight: 2,
-      //   fillColor: "#0ab8d9",
-      //   fillOpacity: 0.3,
-      //   position: [
-      //     { lng: 117.00653126895332, lat: 36.60218701980177 },
-      //     { lng: 117.01254759529783, lat: 36.62184416526905 },
-      //     { lng: 117.0157140828476, lat: 36.62694909036575 },
-      //     { lng: 117.01729732662244, lat: 36.639709910958565 },
-      //     { lng: 117.01983051666225, lat: 36.64430328450691 },
-      //     { lng: 117.01959564703613, lat: 36.662122849219024 },
-      //     { lng: 117.01920551782146, lat: 36.662093109818656 },
-      //   ],
-      // },
       {
         strokeColor: "#66ccff",
-        strokeWeight: 2,
+        strokeWeight: 1,
         fillColor: "#0ab8d9",
         fillOpacity: 0.3,
         position: [
@@ -207,6 +215,48 @@ export const PipeData = [
           { lng: 117.03146584479022, lat: 36.66625383322674 },
         ],
       },
+      {
+        strokeColor: "#f5b209",
+        strokeWeight: 1,
+        fillColor: "#0ab8d9",
+        fillOpacity: 0.3,
+        position: [
+          { lng: 117.05157290392059, lat: 36.65425599872946 },
+          { lng: 117.05142990321565, lat: 36.66673777995204 },
+        ],
+      },
+      {
+        strokeColor: "#0ab8d9",
+        strokeWeight: 1,
+        fillColor: "#0ab8d9",
+        fillOpacity: 0.3,
+        position: [
+          { lng: 117.06234752055991, lat: 36.65388149299456 },
+          { lng: 117.06242336753189, lat: 36.666836903332815 },
+        ],
+      },
+      {
+        strokeColor: "#f5b209",
+        strokeWeight: 1,
+        fillColor: "#0ab8d9",
+        fillOpacity: 0.3,
+        position: [
+          { lng: 117.04449609396455, lat: 36.660724324243404 },
+          { lng: 117.07872863780972, lat: 36.66054326540414 },
+        ],
+      },
+      {
+        strokeColor: "#0ab8d9",
+        strokeWeight: 1,
+        fillColor: "#0ab8d9",
+        fillOpacity: 0.3,
+        position: [
+          { lng: 117.05161592287183, lat: 36.654273196532074 },
+          { lng: 117.05144476564308, lat: 36.64921619878744 },
+          { lng: 117.05503906744678, lat: 36.64480254518266 },
+          { lng: 117.05446854335095, lat: 36.64383702444609 },
+        ],
+      },
     ],
   },
 ];

+ 1 - 0
src/components/Overview/EnergyRanking .js

@@ -23,6 +23,7 @@ class EnergyRanking extends PureComponent {
         { value: 0.81, name: "东郊水厂" },
         { value: 0.9, name: "鹊华水厂" },
       ],
+      showValue: true,
       unit: "kWh/m3",
     };
     const config = {

+ 45 - 34
src/components/centerPage/charts/BMap.js

@@ -1,5 +1,5 @@
 import React, { PureComponent } from "react";
-import { Map, DrawingManager } from "react-bmapgl";
+import { Map, DrawingManager, CustomOverlay } from "react-bmapgl";
 import { styleJson } from "./BMapConfig";
 import styled from "styled-components";
 import Project, { IconType } from "../../Map/Project";
@@ -8,6 +8,7 @@ import MockData, {
   PipeData,
   ShowIconType,
   WaterWorks,
+  pipeTipData,
 } from "../../Map/MockData";
 import Legend from "../../Map/Legend";
 import DrawDom from "./DrawDom";
@@ -35,38 +36,38 @@ class BMap extends PureComponent {
 
   componentDidMount() {
     // this.initData();
-    // var styleOptions = {
-    //   strokeColor: "#5E87DB", // 边线颜色
-    //   fillColor: "#5E87DB", // 填充颜色。当参数为空时,圆形没有填充颜色
-    //   strokeWeight: 2, // 边线宽度,以像素为单位
-    //   strokeOpacity: 1, // 边线透明度,取值范围0-1
-    //   fillOpacity: 0.2, // 填充透明度,取值范围0-1
-    // };
-    // var labelOptions = {
-    //   borderRadius: "2px",
-    //   background: "#FFFBCC",
-    //   border: "1px solid #E1E1E1",
-    //   color: "#703A04",
-    //   fontSize: "12px",
-    //   letterSpacing: "0",
-    //   padding: "5px",
-    // };
-    // // 实例化鼠标绘制工具
-    // this.drawingManager = new BMapGLLib.DrawingManager(this.map, {
-    //   // isOpen: true, // 是否开启绘制模式
-    //   enableCalculate: false, // 绘制是否进行测距测面
-    //   enableSorption: true, // 是否开启边界吸附功能
-    //   sorptiondistance: 20, // 边界吸附距离
-    //   circleOptions: styleOptions, // 圆的样式
-    //   polylineOptions: styleOptions, // 线的样式
-    //   polygonOptions: styleOptions, // 多边形的样式
-    //   rectangleOptions: styleOptions, // 矩形的样式
-    //   labelOptions: labelOptions, // label样式
-    // });
-    // this.drawingManager.addEventListener(
-    //   "polylinecomplete",
-    //   this.polylinecomplete
-    // );
+    var styleOptions = {
+      strokeColor: "#5E87DB", // 边线颜色
+      fillColor: "#5E87DB", // 填充颜色。当参数为空时,圆形没有填充颜色
+      strokeWeight: 2, // 边线宽度,以像素为单位
+      strokeOpacity: 1, // 边线透明度,取值范围0-1
+      fillOpacity: 0.2, // 填充透明度,取值范围0-1
+    };
+    var labelOptions = {
+      borderRadius: "2px",
+      background: "#FFFBCC",
+      border: "1px solid #E1E1E1",
+      color: "#703A04",
+      fontSize: "12px",
+      letterSpacing: "0",
+      padding: "5px",
+    };
+    // 实例化鼠标绘制工具
+    this.drawingManager = new BMapGLLib.DrawingManager(this.map, {
+      // isOpen: true, // 是否开启绘制模式
+      enableCalculate: false, // 绘制是否进行测距测面
+      enableSorption: true, // 是否开启边界吸附功能
+      sorptiondistance: 20, // 边界吸附距离
+      circleOptions: styleOptions, // 圆的样式
+      polylineOptions: styleOptions, // 线的样式
+      polygonOptions: styleOptions, // 多边形的样式
+      rectangleOptions: styleOptions, // 矩形的样式
+      labelOptions: labelOptions, // label样式
+    });
+    this.drawingManager.addEventListener(
+      "polylinecomplete",
+      this.polylinecomplete
+    );
   }
   polylinecomplete(e, overlay) {
     console.log(e.getPath().length);
@@ -136,6 +137,15 @@ class BMap extends PureComponent {
     return list;
   }
 
+  renderTip(data) {
+    const { name, position } = data;
+    return (
+      <CustomOverlay position={position}>
+        <div style={{ color: "yellow" }}>{name}</div>
+      </CustomOverlay>
+    );
+  }
+
   render() {
     const { MockData, active, data } = this.state;
     return (
@@ -195,8 +205,9 @@ class BMap extends PureComponent {
               })
             );
           })}
+          {pipeTipData.map((item) => this.renderTip(item))}
         </Map>
-        {/* <DrawDom draw={this.draw} /> */}
+        <DrawDom draw={this.draw} />
         <Legend
           list={[...data, { type: -1, name: "全部" }]}
           active={active}