|
@@ -1152,23 +1152,59 @@
|
|
|
};
|
|
|
})
|
|
|
</script>
|
|
|
+<% if (hadMap || ctx.session.sessionUser.is_admin) { %>
|
|
|
+<script src="/public/js/map/turf.min.js"></script>
|
|
|
+<script>
|
|
|
+ const tenderMapList = JSON.parse(unescape('<%- escape(JSON.stringify(tenderMapList)) %>'));
|
|
|
+</script>
|
|
|
+<% } %>
|
|
|
<% if (hadMap) { %>
|
|
|
<!--<script src="//bj.bcebos.com/v1/mapopen/api-demos/js/mapStyle.js"></script>-->
|
|
|
<script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=C3hLZAjuWTaCdwnwoYY83APrwlPEj4v7"></script>
|
|
|
<script type="text/javascript">
|
|
|
- var map = new BMapGL.Map("map");
|
|
|
- // 创建地图实例
|
|
|
- var point = new BMapGL.Point(113.462, 22.2245);
|
|
|
- // 初始化地图,设置中心点坐标和地图级别
|
|
|
- map.centerAndZoom(point, 12);
|
|
|
- map.enableScrollWheelZoom(true);
|
|
|
- map.setMapStyleV2({styleId: '20d4aea41cf71387395f2dc835f1c4b6'});
|
|
|
// 画线
|
|
|
- var polyline = new BMapGL.Polyline([
|
|
|
- new BMapGL.Point(113.352, 22.166),
|
|
|
- new BMapGL.Point(113.572, 22.283),
|
|
|
- // new BMapGL.Point(116.425, 39.900)
|
|
|
- ], {strokeColor:"red", strokeWeight:5, strokeOpacity:1});
|
|
|
- map.addOverlay(polyline);
|
|
|
+ $(function () {
|
|
|
+ const map = new BMapGL.Map("map");
|
|
|
+ // 创建地图实例
|
|
|
+
|
|
|
+ const polyLineList = [];
|
|
|
+ const centerPoint = { lng: 116.404, lat: 39.915 };
|
|
|
+ const pointList = [];
|
|
|
+ for (const tm of tenderMapList) {
|
|
|
+ if (tm.map_json) {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ polyLineList.push({
|
|
|
+ map: lngLatList,
|
|
|
+ color: tm.color,
|
|
|
+ });
|
|
|
+ const center = JSON.parse(tm.center);
|
|
|
+ pointList.push(turf.point([center.lng, center.lat]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pointList.length > 0) {
|
|
|
+ const features = turf.featureCollection(pointList);
|
|
|
+ const center = turf.center(features);
|
|
|
+ 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 point = new BMapGL.Point(centerPoint.lng, centerPoint.lat);
|
|
|
+ map.centerAndZoom(point, 14);
|
|
|
+ map.enableScrollWheelZoom(true);
|
|
|
+ map.setMapStyleV2({styleId: '20d4aea41cf71387395f2dc835f1c4b6'});
|
|
|
+ if (polyLineList.length > 0) {
|
|
|
+ for (const pl of polyLineList) {
|
|
|
+ const polyline = new BMapGL.Polyline(pl.map, {strokeColor: pl.color, strokeWeight:5, strokeOpacity:1});
|
|
|
+ map.addOverlay(polyline);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
</script>
|
|
|
<% } %>
|