From 4b9b76e141865b150cd2fdba139f9a80b39dc7e9 Mon Sep 17 00:00:00 2001
From: chenzeping <ChenZeping02609@163.com>
Date: 星期三, 10 三月 2021 18:25:57 +0800
Subject: [PATCH] 文字标注
---
src/components/plugin/MakeTation.js | 63 +++++++++++++++++++++++++++++--
1 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/src/components/plugin/MakeTation.js b/src/components/plugin/MakeTation.js
index 5bc8ac3..9aedc5e 100644
--- a/src/components/plugin/MakeTation.js
+++ b/src/components/plugin/MakeTation.js
@@ -8,6 +8,8 @@
layers: null,
polyline: null,
marker: null,
+ changeColor: '',
+ changeContent: '',
init: function (map, L) {
// console.log(L)
TextAnnotation.L = L
@@ -18,11 +20,14 @@
TextAnnotation.layers = L.layerGroup()
map.on('click', TextAnnotation.click).on('dblclick', TextAnnotation.dblclick)
},
+ setContent :function (changeContent) {
+ console.log(changeContent)
+ TextAnnotation.changeContent = changeContent
+ },
click: function (e) {
- // console.log(e)
- let contents = 'bouncedText'
+ console.log(TextAnnotation.changeContent)
let labIcon = L.divIcon({
- html: '<div style="color: red;font-size: 18px;">' + contents + '</div>',
+ html: '<div style="color: red;font-size: 18px;">' + TextAnnotation.changeContent + '</div>',
iconSize: [100, 40],
iconAnchor: [0, 0],
className: ''
@@ -46,8 +51,56 @@
}
}
+// 娣诲姞 鐐� 鐨勬爣娉�
+var CircleAnnotation = {
+ points: [],
+ color: 'yellow',
+ 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)
+ },
+ click: function (e) {
+ // var myIcon = L.divIcon({className: 'my-div-icon'});
+ let marker = L.marker(e.latlng)
+ marker.addTo(CircleAnnotation.map)
+ },
+ dblclick: function (e) {
+ CircleAnnotation.map.off('click', CircleAnnotation.click).off('dblclick', CircleAnnotation.dblclick)
+ },
+ destory: function () {
+ if (CircleAnnotation.polyline) {
+ CircleAnnotation.map.removeLayer(CircleAnnotation.polyline)
+ }
+ if (CircleAnnotation.marker) {
+ CircleAnnotation.marker.remove()
+ }
+ if (CircleAnnotation.layers) {
+ CircleAnnotation.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 clearText = function () {
@@ -55,5 +108,7 @@
}
export default {
startMakeText,
- clearText
+ clearText,
+ StartCircleAnnotation,
+ setContentText
}
--
Gitblit v1.8.0