临时提交
This commit is contained in:
@@ -234,22 +234,23 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 添加图层, 数据坐标系由控件内完成,输入和输出永远是wgs84
|
* 添加图层, 数据坐标系由控件内完成,输入和输出永远是wgs84
|
||||||
* @param data
|
* [
|
||||||
* [
|
* {
|
||||||
* {
|
*
|
||||||
*
|
* position: [119.1212,45,122],
|
||||||
* position: [119.1212,45,122],
|
* image: {
|
||||||
* image: {
|
* src:"/images/123.png",
|
||||||
* src:"/images/123.png",
|
* anchor: [0.5, 0.5]
|
||||||
* anchor: [0.5, 0.5]
|
*
|
||||||
*
|
* }
|
||||||
* }
|
* }
|
||||||
* }
|
*
|
||||||
*
|
* ]
|
||||||
* ]
|
* @param data
|
||||||
*/
|
* @param clickEvent
|
||||||
addLayer(data, clickEvent) {
|
*/
|
||||||
|
addPointLayer(data, clickEvent) {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
const features = []
|
const features = []
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
@@ -290,7 +291,7 @@ export default {
|
|||||||
return vectorLayer
|
return vectorLayer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateLayer(layer, data, postponement) {
|
updatePointLayer(layer, data, postponement) {
|
||||||
layer.getSource().clear(true)
|
layer.getSource().clear(true)
|
||||||
const features = []
|
const features = []
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
@@ -310,7 +311,7 @@ export default {
|
|||||||
if (postponement) {
|
if (postponement) {
|
||||||
olMap.removeLayer(layer)
|
olMap.removeLayer(layer)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
olMap.addLayer(layer)
|
olMap.addPointLayer(layer)
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
return layer
|
return layer
|
||||||
@@ -371,7 +372,7 @@ export default {
|
|||||||
const vectorLayer = new VectorLayer({
|
const vectorLayer = new VectorLayer({
|
||||||
source: source
|
source: source
|
||||||
})
|
})
|
||||||
olMap.addLayer(vectorLayer)
|
olMap.addPointLayer(vectorLayer)
|
||||||
return vectorLayer
|
return vectorLayer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -390,6 +391,27 @@ export default {
|
|||||||
// 修正地图的中心点
|
// 修正地图的中心点
|
||||||
olMap.getView().setCenter(fromLonLat(center))
|
olMap.getView().setCenter(fromLonLat(center))
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 根据距离计算经纬度差值,方便前端抽稀计算
|
||||||
|
* @param distance 距离, 单位:像素值
|
||||||
|
* @param zoom 地图层级,默认取值当前层级
|
||||||
|
*/
|
||||||
|
computeDiff(distance, zoom) {
|
||||||
|
if (!distance) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
let resolution;
|
||||||
|
if (!zoom) {
|
||||||
|
resolution = olMap.getView().getResolution()
|
||||||
|
}else {
|
||||||
|
resolution = olMap.getView().getResolutionForZoom(zoom)
|
||||||
|
}
|
||||||
|
let diff = resolution * distance
|
||||||
|
let position = toLonLat([diff, diff])
|
||||||
|
console.log(position)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="map-tool-box-top-left">
|
<div class="map-tool-box-top-left">
|
||||||
<div class="map-tool-btn-group">
|
<div class="map-tool-btn-group">
|
||||||
<div class="map-tool-btn" title="图层抽稀">
|
<div class="map-tool-btn" title="图层抽稀" @click="drawThin">
|
||||||
<i class="iconfont icon-mti-sandian"></i> <span>图层抽稀</span>
|
<i class="iconfont icon-mti-sandian"></i> <span>图层抽稀</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="map-tool-btn" title="位置编辑" @click="testArray">
|
<div class="map-tool-btn" title="位置编辑" @click="testArray">
|
||||||
@@ -214,9 +214,9 @@ export default {
|
|||||||
},
|
},
|
||||||
updateChannelLayer: function(array) {
|
updateChannelLayer: function(array) {
|
||||||
if (this.channelLayer) {
|
if (this.channelLayer) {
|
||||||
this.channelLayer = this.$refs.mapComponent.updateLayer(this.channelLayer, array, true)
|
this.channelLayer = this.$refs.mapComponent.updatePointLayer(this.channelLayer, array, true)
|
||||||
}else {
|
}else {
|
||||||
this.channelLayer = this.$refs.mapComponent.addLayer(array, data => {
|
this.channelLayer = this.$refs.mapComponent.addPointLayer(array, data => {
|
||||||
this.closeInfoBox()
|
this.closeInfoBox()
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (data[0].edit) {
|
if (data[0].edit) {
|
||||||
@@ -388,6 +388,13 @@ export default {
|
|||||||
},
|
},
|
||||||
testArray: function (){
|
testArray: function (){
|
||||||
this.$store.dispatch('commonChanel/test')
|
this.$store.dispatch('commonChanel/test')
|
||||||
|
},
|
||||||
|
drawThin: function (){
|
||||||
|
// 假设抽稀的距离
|
||||||
|
let distance = 1000
|
||||||
|
// 根据距离计算经纬度差值
|
||||||
|
let diff = this.$refs.mapComponent.computeDiff(distance)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user