文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 0e79b9d3 by 李梓桢

layer

parent c9074c8c
......@@ -306,7 +306,7 @@
// 双击显示详细信息
markInfo (index) {
// 改变中心位置
this.jumpByPosition(this.landmarkData[index].X, this.landmarkData[index].Y)
this.setCenter('mark', this.landmarkData[index])
this.isMark = true
this.labelNow = index
......@@ -317,7 +317,9 @@
},
areaInfo (index) {
this.findCenter(this.layerData[index].pointList)
// 改变中心位置
this.setCenter('polygon', this.layerData[index].pointList)
this.isMark = false
this.labelNow = index
this.isInfo = true
......@@ -366,7 +368,7 @@
this.map.add(polygon)
})
},
// 计算多边形几何中心
// 计算多边形几何中心, 没有使用的函数
findCenter(pointList){
var minX = 1000
var minY = 1000
......@@ -424,8 +426,25 @@
this.map.add(polygon)
})
},
setCenter () {
this.map.setCenter([this.centerY, this.centerX])
setCenter (type, pointList) {
if(type == 'mark') {
var tmp = new AMap.Marker({
position: new AMap.LngLat(pointList.X, pointList.Y), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
title: 'tmp'
});
}else if(type == 'polygon') {
var path = []
pointList.forEach(e => {
path.push(new AMap.LngLat(e.X, e.Y))
})
var tmp = new AMap.Polygon({
path: path,
fillColor: '#fff', // 多边形填充颜色
borderWeight: 2, // 线条宽度,默认为 1
strokeColor: 'red', // 线条颜色
})
}
this.map.setFitView(tmp)
},
/**
* 还原数据中的地标、标注区域
......
......@@ -315,6 +315,9 @@
},
// 双击显示详细信息
markInfo (index) {
// 改变中心位置
this.setCenter('mark', this.landmarkData[index])
this.isMark = true
this.labelNow = index
this.isInfo = true
......@@ -323,7 +326,11 @@
this.labelPosition = 'X:' + this.landmarkData[index].X + '\nY:' + this.landmarkData[index].Y
},
areaInfo (index) {
// 改变中心位置
this.setCenter('polygon', this.layerData[index].pointList)
this.isMark = false
this.labelNow = index
this.isInfo = true
......@@ -372,6 +379,26 @@
this.map.add(polygon)
})
},
// 计算多边形几何中心,没有使用的函数
findCenter(pointList){
var minX = 1000
var minY = 1000
var maxX = -1000
var maxY = -1000
pointList.forEach((element, i) => {
if (element.X < minX)
minX = element.X
if (element.X > maxX)
maxX = element.X
if (element.Y < minY)
minY = element.Y
if (element.Y > maxY)
maxY = element.Y
})
let midX = (minX + maxX)/ 2
let midY = (minY + maxY)/ 2
this.jumpByPosition(midX, midY)
},
markEnter (index) {
//还原地标
this.map.clearMap()
......@@ -409,8 +436,25 @@
this.map.add(polygon)
})
},
setCenter () {
this.map.setCenter([this.centerY, this.centerX])
setCenter (type, pointList) {
if(type == 'mark') {
var tmp = new AMap.Marker({
position: new AMap.LngLat(pointList.X, pointList.Y), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
title: 'tmp'
});
}else if(type == 'polygon') {
var path = []
pointList.forEach(e => {
path.push(new AMap.LngLat(e.X, e.Y))
})
var tmp = new AMap.Polygon({
path: path,
fillColor: '#fff', // 多边形填充颜色
borderWeight: 2, // 线条宽度,默认为 1
strokeColor: 'red', // 线条颜色
})
}
this.map.setFitView(tmp)
},
/**
* 还原数据中的地标、标注区域
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment