From c88c7017a1e5ef46e297d579aea93cb4df83a60a Mon Sep 17 00:00:00 2001
From: xiebin <123456>
Date: Thu, 22 Sep 2022 10:08:21 +0800
Subject: [PATCH] 定位图标修改、提示信息优化、右键绘画提示信息失效问题
---
src/components/OpenLayersMap/index.vue | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/components/OpenLayersMap/index.vue b/src/components/OpenLayersMap/index.vue
index eab6596..7836c22 100644
--- a/src/components/OpenLayersMap/index.vue
+++ b/src/components/OpenLayersMap/index.vue
@@ -76,8 +76,8 @@
projection: 'EPSG:4326',
// 设置缩放倍数
zoom: 13,
- minZoom: 6,
- maxZoom: 20
+ minZoom: 8,
+ maxZoom: 19
})
})
_this.lineVector = new VectorLayer({
@@ -144,7 +144,7 @@
this.lineVector.getSource().addFeature(feature_LineString);
}
},
- //添加点
+ // 添加点
addPoint(pointLonLat){
if (pointLonLat){
//设置点
@@ -154,15 +154,16 @@
//点样式
let style = new Style({
image: new Icon({
- src: "/img/favicon.png",
+ src: "/img/dwicon.jpeg",
anchor: [0.48, 0.52],
- scale:0.5
+ // imgSize: [250,320],
+ scale: 0.2
}),
});
feature_Point.setStyle(style);
this.pointVector.getSource().addFeature(feature_Point);
- var center = [Number(pointLonLat.lon), Number(pointLonLat.lat)];
- var view = this.map.getView();
+ let center = [Number(pointLonLat.lon), Number(pointLonLat.lat)];
+ let view = this.map.getView();
view.setZoom(16);
view.animate({
center: center,
@@ -193,11 +194,14 @@
if(!_this.showTip){
_this.showTip = true
}
- _this.tipTitle = "单击左键开始绘画";
+ _this.tipTitle = "单击左键或者右键开始绘画"
//提示器
$("#map").off("mousemove").mousemove(function (e) {
_this.setTipPosition(e.offsetX, e.offsetY, 5, 5);
- });
+ })
+ $("#map").off("mousedown").mousedown(function () {
+ _this.tipTitle = "可继续,或选择最终位置双击结束绘画"
+ })
_this.draw = new Draw({
source: _this.lineVector.getSource(),
@@ -214,7 +218,6 @@
_this.map.on('click', function (e) {
// 将点坐标保存集合
_this.coordinates.push(e.coordinate)
- _this.tipTitle = "可继续,或单击鼠标结束";
})
// 结束事件
_this.draw.on('drawend', function () {
@@ -285,7 +288,7 @@
vectorLayer.getSource().addFeature(feature)// 将Feature对象填入图层源
this.map.addLayer(vectorLayer) // 将图层添至地图对象
},
- //画多边形
+ // 画多边形
drawPolygon(point) {
this.polygonPoints.push(point)
let feature = new Feature({
@@ -353,6 +356,7 @@
this.map.addLayer(clusters)
},
+ // 重置图层
clearDraw(){
let _this = this
_this.coordinates = []
@@ -382,7 +386,7 @@
// }
})
},
- //设置提示位置
+ // 设置提示位置
setTipPosition(x, y, n, m) {
let _this = this
_this.tipPosition.w = x + n;
--
Gitblit v1.9.3