Browse Source

坐标系更换

laiguoran 3 years ago
parent
commit
9a1d7d6863
2 changed files with 26 additions and 1 deletions
  1. 20 0
      app/public/js/map/gcoord.js
  2. 6 1
      app/view/tender/detail.ejs

File diff suppressed because it is too large
+ 20 - 0
app/public/js/map/gcoord.js


+ 6 - 1
app/view/tender/detail.ejs

@@ -1169,6 +1169,7 @@
 </script>
 <% if (hadMap || ctx.session.sessionUser.is_admin) { %>
     <script src="/public/js/map/turf.min.js"></script>
+    <script src="/public/js/map/gcoord.js"></script>
     <script>
         const tenderMapList = JSON.parse(unescape('<%- escape(JSON.stringify(tenderMapList)) %>'));
     </script>
@@ -1190,7 +1191,8 @@
                     const map_json = JSON.parse(unescape(escape(tm.map_json)));
                     const lngLatList = [];
                     for (const mj of map_json) {
-                        lngLatList.push(new BMapGL.Point(mj.lng, mj.lat));
+                        const result = gcoord.transform([mj.lng, mj.lat], gcoord.WGS84, gcoord.BD09);
+                        lngLatList.push(new BMapGL.Point(result[0], result[1]));
                     }
                     polyLineList.push({
                         map: lngLatList,
@@ -1206,6 +1208,9 @@
                 if (center && center.geometry && center.geometry.coordinates && center.geometry.coordinates.length === 2) {
                     centerPoint.lng = _.round(center.geometry.coordinates[0], 4);
                     centerPoint.lat = _.round(center.geometry.coordinates[1], 4);
+                    const result = gcoord.transform([centerPoint.lng, centerPoint.lat], gcoord.WGS84, gcoord.BD09);
+                    centerPoint.lng = result[0];
+                    centerPoint.lat = result[1];
                 }
             }
             // 初始化地图,设置中心点坐标和地图级别