diff --git a/src/apps/AppGridManagement/Map.vue b/src/apps/AppGridManagement/Map.vue index 669bdbe7..744bf2b7 100644 --- a/src/apps/AppGridManagement/Map.vue +++ b/src/apps/AppGridManagement/Map.vue @@ -11,7 +11,7 @@
- +
+
+
+ 网格长 + {{ item.name }}  {{ item.phone }} + + +
+
网格管理员 @@ -74,9 +83,10 @@ export default { if (res?.data) { this.treeList = res.data - const arr = res.data.map(e => { + const arr = res.data.filter(v => v.points).map(e => { return { id: e.id, + girdName: e.girdName, points: e.points.map(p => [p.lng, p.lat]) } }) @@ -111,8 +121,8 @@ export default { } if (paths?.length > 0) { let bounds = [] + paths.forEach((path, i) => { - console.log(path) let color = colors[i % colors.length] let polygon = new TMap.MultiPolygon({ map, styles: { @@ -135,10 +145,33 @@ export default { }) const points = path.points.map(e => new TMap.LatLng(e[1], e[0])) - - // console.log(TMap) - // var position = TMap.geometry.computeCentroid(points) + var position = TMap.geometry.computeCentroid(points) + + let label = new TMap.MultiLabel({ + id: `label~${path.id}`, + data: path.id, + map: map, + styles: { + building: new TMap.LabelStyle({ + color: '#3777FF', + size: 20, + alignment: 'center', + verticalAlignment: 'middle' + }) + }, + geometries: [ + { + id: `label-class-${i}`, + styleId: 'building', + position: position, + content: path.girdName, + } + ] + }) + label.on('click', e => { + this.getGridInfo(e.target.id.split('~')[1]) + }); }) bounds = bounds.reduce((a, b) => { return fitBounds([ @@ -166,9 +199,10 @@ export default { }, handleSelect(e) { if (e?.points?.length > 0) { - this.form = e - let path = e.points?.map(p => [p.lng, p.lat]) || [] - this.renderGridMap([path]) + const points = e.points.map(e => new TMap.LatLng(e.lat, e.lng)) + var position = TMap.geometry.computeCentroid(points) + this.map.setCenter(position) + this.map.setZoom(15) } else { this.$u.toast("所选网格没有标绘!") } diff --git a/src/components/AiTMap.vue b/src/components/AiTMap.vue index c1e3165f..ada7504e 100644 --- a/src/components/AiTMap.vue +++ b/src/components/AiTMap.vue @@ -57,7 +57,6 @@ export default { center: new TMap.LatLng(this.config.lat, this.config.lng), ...this.ops }) - console.log(TMap) this.$emit('loaded') this.$emit('update:lib', TMap) this.$emit('update:map', this.tmap)