优化代码

This commit is contained in:
wuxw 2024-06-18 09:13:44 +08:00
parent 0b0e3b1b83
commit 16b7fa7834
3 changed files with 40 additions and 4 deletions

View File

@ -86,15 +86,24 @@
_pos.forEach(_m => { _pos.forEach(_m => {
try { try {
let center = new TMap.LatLng(_m.lat, _m.lng); let center = new TMap.LatLng(_m.lat, _m.lng);
let _markerStyle = 'myStyle';
if(_m.state == '20200405'){
_markerStyle = 'myStyle_red';
}
_geometriesMarker.push({ _geometriesMarker.push({
"id": _m.inspectionId, //点标记唯一标识后续如果有删除、修改位置等操作都需要此id "id": _m.inspectionId, //点标记唯一标识后续如果有删除、修改位置等操作都需要此id
"styleId": 'myStyle', //指定样式id "styleId": _markerStyle, //指定样式id
"position": center, //点标记坐标位置 "position": center, //点标记坐标位置
}); });
let _layerStyle = 'label';
if(_m.state == '20200405'){
_layerStyle = 'label_red';
}
_geometriesLabel.push({ _geometriesLabel.push({
'id': 'label_' + _m.inspectionId, //点图形数据的标志信息 'id': 'label_' + _m.inspectionId, //点图形数据的标志信息
'styleId': 'label', //样式id 'styleId': _layerStyle, //样式id
'position': center, //标注点位置 'position': center, //标注点位置
// 'content': _m.staffName, //标注文本 // 'content': _m.staffName, //标注文本
'content': _m.inspectionName 'content': _m.inspectionName
@ -112,7 +121,14 @@
"myStyle": new TMap.MarkerStyle({ "myStyle": new TMap.MarkerStyle({
"width": 25, // 点标记样式宽度(像素) "width": 25, // 点标记样式宽度(像素)
"height": 35, // 点标记样式高度(像素) "height": 35, // 点标记样式高度(像素)
"src": '/img/maper.png', //图片路径 "src": '/img/inspection.png', //图片路径
//焦点在图片中的像素位置,一般大头针类似形式的图片以针尖位置做为焦点,圆形点以圆心位置为焦点
"anchor": { x: 32, y: 32 }
}),
"myStyle_red": new TMap.MarkerStyle({
"width": 25, // 点标记样式宽度(像素)
"height": 35, // 点标记样式高度(像素)
"src": '/img/inspection_do.png', //图片路径
//焦点在图片中的像素位置,一般大头针类似形式的图片以针尖位置做为焦点,圆形点以圆心位置为焦点 //焦点在图片中的像素位置,一般大头针类似形式的图片以针尖位置做为焦点,圆形点以圆心位置为焦点
"anchor": { x: 32, y: 32 } "anchor": { x: 32, y: 32 }
}) })
@ -133,6 +149,14 @@
'angle': 0, //文字旋转属性 'angle': 0, //文字旋转属性
'alignment': 'center', //文字水平对齐属性 'alignment': 'center', //文字水平对齐属性
'verticalAlignment': 'middle' //文字垂直对齐属性 'verticalAlignment': 'middle' //文字垂直对齐属性
}),
'label_red': new TMap.LabelStyle({
'color': '#CC0000', //颜色属性
'size': 20, //文字大小属性
'offset': { x: 0, y: 15 }, //文字偏移属性单位为像素
'angle': 0, //文字旋转属性
'alignment': 'center', //文字水平对齐属性
'verticalAlignment': 'middle' //文字垂直对齐属性
}) })
}, },
//文字标记数据 //文字标记数据
@ -150,7 +174,14 @@
'borderWidth': 5, //边线宽度 'borderWidth': 5, //边线宽度
'borderColor': '#FFF', //边线颜色 'borderColor': '#FFF', //边线颜色
'lineCap': 'butt' //线端头方式 'lineCap': 'butt' //线端头方式
}) }),
'style_red': new TMap.PolylineStyle({
'color': '#CC0000', //线填充色
'width': 6, //折线宽度
'borderWidth': 5, //边线宽度
'borderColor': '#FFF', //边线颜色
'lineCap': 'butt' //线端头方式
}),
}, },
//折线数据定义 //折线数据定义
geometries: [ geometries: [
@ -158,6 +189,11 @@
'id': 'pl_1',//折线唯一标识,删除时使用 'id': 'pl_1',//折线唯一标识,删除时使用
'styleId': 'style_blue',//绑定样式名 'styleId': 'style_blue',//绑定样式名
'paths': _path 'paths': _path
},
{//第1条线
'id': 'pl_2',//折线唯一标识,删除时使用
'styleId': 'style_red',//绑定样式名
'paths': _path
} }
] ]
}); });

BIN
public/img/inspection.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB