From 0b0e3b1b8366b341120d6236bf8f0db563249bae Mon Sep 17 00:00:00 2001 From: wuxw <928255095@qq.com> Date: Tue, 18 Jun 2024 00:58:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspectionTaskMap/inspectionTaskMap.js | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/public/components/inspection/inspectionTaskMap/inspectionTaskMap.js b/public/components/inspection/inspectionTaskMap/inspectionTaskMap.js index 43d7b576e..b17a6c919 100644 --- a/public/components/inspection/inspectionTaskMap/inspectionTaskMap.js +++ b/public/components/inspection/inspectionTaskMap/inspectionTaskMap.js @@ -1,43 +1,43 @@ /** 业主详情页面 **/ -(function(vc) { +(function (vc) { vc.extends({ data: { inspectionTaskMapInfo: { datas: [], - map:{} - + map: {} + } }, - _initMethod: function() { + _initMethod: function () { }, - _initEvent: function() { - vc.on('inspectionTaskMap','initMap',function(_data){ + _initEvent: function () { + vc.on('inspectionTaskMap', 'initMap', function (_data) { $that._queryInspectionTaskMap(_data); }); }, methods: { - _queryInspectionTaskMap:function(_route){ + _queryInspectionTaskMap: function (_route) { let param = { params: { communityId: vc.getCurrentCommunity().communityId, - inspectionRouteId: _route.inspectionRouteId, + taskId: _route.taskId, page: 1, row: 1000 } }; //发送get请求 - vc.http.apiGet('/inspectionRoute.listInspectionRoutePoints', + vc.http.apiGet('/inspection.queryInspectionTaskDetail', param, function (json) { let _json = JSON.parse(json); - $that.inspectionTaskMapInfo.data = _json.inspectionPoints; + $that.inspectionTaskMapInfo.data = _json.data; - $that.initInspectionTaskMap(_json.inspectionPoints); + $that.initInspectionTaskMap(_json.data); }, function () { @@ -45,19 +45,25 @@ } ); }, - initInspectionTaskMap:function(_pos) { + initInspectionTaskMap: function (_pos) { let _lng = 116.307484; let _lat = 39.984120; // _pos.forEach(_m => { // let _latLon = wgs84togcj02(_m.lng,_m.lat); - + // }); - - if (_pos && _pos.length > 0) { - _lat = _pos[0].lat; - _lng = _pos[0].lng; + + if (!_pos || _pos.length < 1) { + return; } - + _pos.forEach(_p => { + if (_p.lat) { + _lat = _p.lat; + _lng = _p.lng; + } + }); + + let center = new TMap.LatLng(_lat, _lng) //定义map变量,调用 TMap.Map() 构造函数创建地图 let map = new TMap.Map(document.getElementById('inspectionTaskMap'), { @@ -72,30 +78,30 @@ $that.inspectionTaskMapInfo.map = map; $that._addTaskPointMachine(_pos); }, - _addTaskPointMachine:function(_pos) { + _addTaskPointMachine: function (_pos) { let _geometriesMarker = []; let _geometriesLabel = []; let _path = []; - + _pos.forEach(_m => { - try{ + try { let center = new TMap.LatLng(_m.lat, _m.lng); _geometriesMarker.push({ "id": _m.inspectionId, //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id "styleId": 'myStyle', //指定样式id "position": center, //点标记坐标位置 }); - + _geometriesLabel.push({ 'id': 'label_' + _m.inspectionId, //点图形数据的标志信息 'styleId': 'label', //样式id 'position': center, //标注点位置 - // 'content': _m.staffName, //标注文本 - 'content':_m.inspectionName + // 'content': _m.staffName, //标注文本 + 'content': _m.inspectionName }); _path.push(center); - }catch(e){ - + } catch (e) { + } }); let markerLayer = new TMap.MultiMarker({ @@ -114,8 +120,8 @@ //点标记数据数组 geometries: _geometriesMarker }); - - var label = new TMap.MultiLabel({ + + let label = new TMap.MultiLabel({ id: 'label-layer', map: $that.inspectionTaskMapInfo.map, //设置折线图层显示到哪个地图实例中 //文字标记样式 @@ -132,8 +138,8 @@ //文字标记数据 geometries: _geometriesLabel }); - - var polylineLayer = new TMap.MultiPolyline({ + + let polylineLayer = new TMap.MultiPolyline({ id: 'polyline-layer', //图层唯一标识 map: $that.inspectionTaskMapInfo.map,//设置折线图层显示到哪个地图实例中 //折线样式定义