优化代码

This commit is contained in:
wuxw 2024-06-18 00:58:42 +08:00
parent 9bdc7edcfa
commit 0b0e3b1b83

View File

@ -25,19 +25,19 @@
let param = { let param = {
params: { params: {
communityId: vc.getCurrentCommunity().communityId, communityId: vc.getCurrentCommunity().communityId,
inspectionRouteId: _route.inspectionRouteId, taskId: _route.taskId,
page: 1, page: 1,
row: 1000 row: 1000
} }
}; };
//发送get请求 //发送get请求
vc.http.apiGet('/inspectionRoute.listInspectionRoutePoints', vc.http.apiGet('/inspection.queryInspectionTaskDetail',
param, param,
function (json) { function (json) {
let _json = JSON.parse(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 () { function () {
@ -53,10 +53,16 @@
// }); // });
if (_pos && _pos.length > 0) { if (!_pos || _pos.length < 1) {
_lat = _pos[0].lat; return;
_lng = _pos[0].lng;
} }
_pos.forEach(_p => {
if (_p.lat) {
_lat = _p.lat;
_lng = _p.lng;
}
});
let center = new TMap.LatLng(_lat, _lng) let center = new TMap.LatLng(_lat, _lng)
//定义map变量调用 TMap.Map() 构造函数创建地图 //定义map变量调用 TMap.Map() 构造函数创建地图
@ -115,7 +121,7 @@
geometries: _geometriesMarker geometries: _geometriesMarker
}); });
var label = new TMap.MultiLabel({ let label = new TMap.MultiLabel({
id: 'label-layer', id: 'label-layer',
map: $that.inspectionTaskMapInfo.map, //设置折线图层显示到哪个地图实例中 map: $that.inspectionTaskMapInfo.map, //设置折线图层显示到哪个地图实例中
//文字标记样式 //文字标记样式
@ -133,7 +139,7 @@
geometries: _geometriesLabel geometries: _geometriesLabel
}); });
var polylineLayer = new TMap.MultiPolyline({ let polylineLayer = new TMap.MultiPolyline({
id: 'polyline-layer', //图层唯一标识 id: 'polyline-layer', //图层唯一标识
map: $that.inspectionTaskMapInfo.map,//设置折线图层显示到哪个地图实例中 map: $that.inspectionTaskMapInfo.map,//设置折线图层显示到哪个地图实例中
//折线样式定义 //折线样式定义