26826
This commit is contained in:
41
packages/2.0.5/AppGridMap/components/list.vue
vendored
41
packages/2.0.5/AppGridMap/components/list.vue
vendored
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="gridMap">
|
<div class="gridMap">
|
||||||
<ai-t-map :map.sync="map" :lib.sync="mapLib"/>
|
<ai-t-map :map.sync="map" :lib.sync="mapLib" :libraries="['geometry','service', 'tools']"/>
|
||||||
<div class="drawer" ref="drawer">
|
<div class="drawer" ref="drawer">
|
||||||
<div v-if="show" class="drawer-content">
|
<div v-if="show" class="drawer-content">
|
||||||
<b>网格地图</b>
|
<b>网格地图</b>
|
||||||
@@ -72,10 +72,12 @@ export default {
|
|||||||
member: {
|
member: {
|
||||||
memberList: [],
|
memberList: [],
|
||||||
},
|
},
|
||||||
|
currInfo: {},
|
||||||
infoWindowHtml: "",
|
infoWindowHtml: "",
|
||||||
marker: {},
|
marker: {},
|
||||||
location: {},
|
location: {},
|
||||||
activeId: null,
|
activeId: null,
|
||||||
|
labels: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -127,6 +129,8 @@ export default {
|
|||||||
},
|
},
|
||||||
handleNodeClick(val) {
|
handleNodeClick(val) {
|
||||||
let path = [];
|
let path = [];
|
||||||
|
console.log(val)
|
||||||
|
this.currInfo = val
|
||||||
if (val?.points?.length > 0) {
|
if (val?.points?.length > 0) {
|
||||||
path = val.points.map(e => [e.lng, e.lat])
|
path = val.points.map(e => [e.lng, e.lat])
|
||||||
this.renderGridMap([path])
|
this.renderGridMap([path])
|
||||||
@@ -140,6 +144,12 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
flag && map.setCenter(new TMap.LatLng(this.location.lat, this.location.lng))
|
flag && map.setCenter(new TMap.LatLng(this.location.lat, this.location.lng))
|
||||||
}, 400)
|
}, 400)
|
||||||
|
if (this.labels.length > 0) {
|
||||||
|
this.labels.forEach(e => {
|
||||||
|
e.destroy(e.id)
|
||||||
|
})
|
||||||
|
this.labels = []
|
||||||
|
}
|
||||||
const colors = ["#A194F4", "#7CBDF3", "#F3A57D", "#62D063", "#58DBDA", "#F7D151"]
|
const colors = ["#A194F4", "#7CBDF3", "#F3A57D", "#62D063", "#58DBDA", "#F7D151"]
|
||||||
const fitBounds = (latLngList) => {
|
const fitBounds = (latLngList) => {
|
||||||
// 由多边形顶点坐标数组计算能完整呈现该多边形的最小矩形范围
|
// 由多边形顶点坐标数组计算能完整呈现该多边形的最小矩形范围
|
||||||
@@ -182,6 +192,35 @@ export default {
|
|||||||
})
|
})
|
||||||
this.polygons.push(polygon)
|
this.polygons.push(polygon)
|
||||||
bounds.push(fitBounds(path.map(e => new TMap.LatLng(e[1], e[0]))))
|
bounds.push(fitBounds(path.map(e => new TMap.LatLng(e[1], e[0]))))
|
||||||
|
|
||||||
|
const points = path.map(e => new TMap.LatLng(e[1], e[0]))
|
||||||
|
var position = TMap.geometry.computeCentroid(points)
|
||||||
|
|
||||||
|
let label = new TMap.MultiLabel({
|
||||||
|
id: `label~${this.currInfo.id}`,
|
||||||
|
data: this.currInfo.id,
|
||||||
|
map: map,
|
||||||
|
styles: {
|
||||||
|
building: new TMap.LabelStyle({
|
||||||
|
color: '#3777FF',
|
||||||
|
size: 30,
|
||||||
|
alignment: 'center',
|
||||||
|
verticalAlignment: 'middle'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
geometries: [
|
||||||
|
{
|
||||||
|
id: `label-class-${i}`,
|
||||||
|
styleId: 'building',
|
||||||
|
position: position,
|
||||||
|
content: this.currInfo.girdName,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
this.labels.push(label)
|
||||||
|
label.on('click', e => {
|
||||||
|
this.getGridInfo(e.target.id.split('~')[1])
|
||||||
|
});
|
||||||
})
|
})
|
||||||
bounds = bounds.reduce((a, b) => {
|
bounds = bounds.reduce((a, b) => {
|
||||||
return fitBounds([
|
return fitBounds([
|
||||||
|
|||||||
Reference in New Issue
Block a user