From b9aa1e3bc9b70df68967b3a37ece51ae1729f5b2 Mon Sep 17 00:00:00 2001
From: chenyabin <Chenab123!>
Date: 星期三, 07 四月 2021 11:39:14 +0800
Subject: [PATCH] 统一样式-图层组件样式修改
---
src/components/plugin/MakeTation.js | 75 +++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 32 deletions(-)
diff --git a/src/components/plugin/MakeTation.js b/src/components/plugin/MakeTation.js
index 9aedc5e..311f7c9 100644
--- a/src/components/plugin/MakeTation.js
+++ b/src/components/plugin/MakeTation.js
@@ -2,7 +2,7 @@
// 娣诲姞鏂囧瓧鏍囨敞
var TextAnnotation = {
points: [],
- color: 'yellow',
+ color: '',
L: null,
map: null,
layers: null,
@@ -20,14 +20,20 @@
TextAnnotation.layers = L.layerGroup()
map.on('click', TextAnnotation.click).on('dblclick', TextAnnotation.dblclick)
},
- setContent :function (changeContent) {
- console.log(changeContent)
+ // 璁剧疆鏀瑰彉鏂囧瓧鍐呭
+ setContent: function (changeContent) {
+ // console.log(changeContent)
TextAnnotation.changeContent = changeContent
},
+ // 璁剧疆鏀瑰彉鏂囧瓧棰滆壊
+ setColor: function (changeColor) {
+ // console.log(changeColor)
+ TextAnnotation.changeColor = changeColor
+ },
click: function (e) {
- console.log(TextAnnotation.changeContent)
+ // console.log(TextAnnotation.changeContent)
let labIcon = L.divIcon({
- html: '<div style="color: red;font-size: 18px;">' + TextAnnotation.changeContent + '</div>',
+ html: '<div style="color:' + TextAnnotation.changeColor + ';font-size: 18px;">' + TextAnnotation.changeContent + '</div>',
iconSize: [100, 40],
iconAnchor: [0, 0],
className: ''
@@ -52,63 +58,68 @@
}
// 娣诲姞 鐐� 鐨勬爣娉�
-var CircleAnnotation = {
+let pointAnnotation = {
points: [],
- color: 'yellow',
+ color: '',
L: null,
map: null,
layers: null,
polyline: null,
marker: null,
init: function (map, L) {
- // console.log(L)
- CircleAnnotation.L = L
- CircleAnnotation.map = map
- CircleAnnotation.points = []
- CircleAnnotation.polyline = null
- CircleAnnotation.marker = null
- CircleAnnotation.layers = L.layerGroup()
- map.on('click', CircleAnnotation.click).on('dblclick', CircleAnnotation.dblclick)
+ pointAnnotation.L = L
+ pointAnnotation.map = map
+ pointAnnotation.points = []
+ pointAnnotation.polyline = null
+ pointAnnotation.marker = null
+ pointAnnotation.layers = L.layerGroup()
+ map.on('click', pointAnnotation.click).on('dblclick', pointAnnotation.dblclick)
},
click: function (e) {
- // var myIcon = L.divIcon({className: 'my-div-icon'});
let marker = L.marker(e.latlng)
- marker.addTo(CircleAnnotation.map)
+ marker.addTo(pointAnnotation.map)
},
dblclick: function (e) {
- CircleAnnotation.map.off('click', CircleAnnotation.click).off('dblclick', CircleAnnotation.dblclick)
+ pointAnnotation.map.off('click', pointAnnotation.click).off('dblclick', pointAnnotation.dblclick)
},
destory: function () {
- if (CircleAnnotation.polyline) {
- CircleAnnotation.map.removeLayer(CircleAnnotation.polyline)
+ if (pointAnnotation.polyline) {
+ pointAnnotation.map.removeLayer(pointAnnotation.polyline)
}
- if (CircleAnnotation.marker) {
- CircleAnnotation.marker.remove()
+ if (pointAnnotation.marker) {
+ pointAnnotation.marker.remove()
}
- if (CircleAnnotation.layers) {
- CircleAnnotation.layers.clearLayers()
+ if (pointAnnotation.layers) {
+ pointAnnotation.layers.clearLayers()
}
}
}
+// 娣诲姞鏂囧瓧鏍囨敞
const startMakeText = function (map, L) {
TextAnnotation.init(map, L)
}
-
-const StartCircleAnnotation = function (map, L) {
- CircleAnnotation.init(map, L)
-}
-
+// 鏂囧瓧鏍囨敞鐨� 鍐呭绀捐缃�
const setContentText = function (text) {
TextAnnotation.setContent(text)
+}
+// 鏂囧瓧鏍囨敞鍐呭鐨� 棰滆壊 璁剧疆
+const setContentColor = function (color) {
+ TextAnnotation.setColor(color)
+}
+
+// 鐐� 鏍囨敞
+const StartPointAnnotation = function (map, L) {
+ pointAnnotation.init(map, L)
}
const clearText = function () {
startMakeText.destory()
}
export default {
- startMakeText,
clearText,
- StartCircleAnnotation,
- setContentText
+ startMakeText,
+ setContentText,
+ setContentColor,
+ StartPointAnnotation
}
--
Gitblit v1.8.0