From 637c7047467508419f7d50d63194b58ab0180f00 Mon Sep 17 00:00:00 2001
From: chenyabin <Chenab123!>
Date: 星期三, 31 三月 2021 15:31:19 +0800
Subject: [PATCH] 添加企业点图层

---
 src/conf/Constants.js                           |    5 +-
 src/api/mapApi.js                               |    3 +
 src/components/LayerController/logic/Company.js |   59 +++++++++++++++++++++++++++++
 src/api/mapUrl.js                               |    2 +
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/src/api/mapApi.js b/src/api/mapApi.js
index ce6c47f..2784a8e 100644
--- a/src/api/mapApi.js
+++ b/src/api/mapApi.js
@@ -14,5 +14,8 @@
   },
   getSolidWaste (data) {
     return axios.get(mapUrl.getSolidWaste, data)
+  },
+  getCompany (data) {
+    return axios.get(mapUrl.getCompany, data)
   }
 }
diff --git a/src/api/mapUrl.js b/src/api/mapUrl.js
index afdb4e3..77cb202 100644
--- a/src/api/mapUrl.js
+++ b/src/api/mapUrl.js
@@ -6,3 +6,5 @@
 export const GetUser = $HOST + '/user/getUser'
 
 export const getSolidWaste = $HOST + '/wasteSolid/getSolidWaste'
+
+export const getCompany = $HOST + '/company/getCompany'
diff --git a/src/components/LayerController/logic/Company.js b/src/components/LayerController/logic/Company.js
new file mode 100644
index 0000000..f4ff3f0
--- /dev/null
+++ b/src/components/LayerController/logic/Company.js
@@ -0,0 +1,59 @@
+/**
+ * 鍥哄簾
+ */
+// 鍖哄垎涓嶅悓绫诲瀷 浣跨敤涓嶅悓img
+const companyImg = '/assets/images/map/company.png'
+
+const mapApi = require('../../../api/mapApi').default
+const AnimalService = require('../service/AnimalService').default
+
+module.exports = function () {
+  /**
+     * 杩斿洖marker瀵硅薄鏁扮粍
+     * @param L leaflet瀵硅薄
+     */
+  this.init = async (layer, L) => {
+    // const SolidWasteIcon = this.SolidWasteIcon()
+    this.animalService = new AnimalService({
+      L: L,
+      layer: layer
+    })
+    const res = await mapApi.getCompany()
+    console.log(res)
+    const data = res.Result.DataInfo || {}
+    for (let i = 0; i < data.length; i++) {
+      // 缁忕含搴� 浣嶇疆
+      const positionX = data[i].Latitude
+      const positionY = data[i].Longitude
+
+      var iconUrl = companyImg
+      const marker = L.marker.magic([positionX, positionY], {
+        icon: L.icon({
+          iconUrl: iconUrl,
+          iconSize: [50, 50],
+          iconAnchor: [25, 25]
+        })
+      })
+
+      layer.addLayer(marker)
+    }
+  }
+
+  this.bindTooltip = (layer) => {
+    console.log(layer)
+    return '浼佷笟'
+  }
+
+  this.clickListener = (layer) => {
+    /* this.animalService.pulseEffect(e.latlng)
+    console.log(e)
+    return this.PublicBounced.$el
+    */
+    console.log(layer)
+  }
+
+  // 鍥哄簾鐐瑰嚮杩涜鐨� 鍐呭鐨勮缃�
+  // SetSolidWasteContent (config, containerPopup) {
+  //   this.SolidWastePopup = containerPopup
+  // }
+}
diff --git a/src/conf/Constants.js b/src/conf/Constants.js
index e2ac498..1a14004 100644
--- a/src/conf/Constants.js
+++ b/src/conf/Constants.js
@@ -5,11 +5,12 @@
 }
 
 export const logicMapper = {
-  fsqy: 'Sample.js',
+  // fsqy: 'Sample.js',
   fspfk: 'Sample.js',
   fsjcd: 'Sample.js',
   wasteGasJcd: 'WasteGas.js',
-  solidWasteJcd: 'SolidWaste.js'
+  solidWasteJcd: 'SolidWaste.js',
+  fsqy: 'Company.js'
 }
 
 export const props = {

--
Gitblit v1.8.0