From f9201f16652d1e58d649afaf0c5d025031c52c3f Mon Sep 17 00:00:00 2001 From: chenzeping <ChenZeping02609@163.com> Date: 星期三, 31 三月 2021 11:16:25 +0800 Subject: [PATCH] 更改文件地址/及方法 --- src/components/LayerController/logic/SolidWaste.js | 65 +++++++++++++++++++++----------- 1 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/components/LayerController/logic/SolidWaste.js b/src/components/LayerController/logic/SolidWaste.js index c92dca2..dfc5841 100644 --- a/src/components/LayerController/logic/SolidWaste.js +++ b/src/components/LayerController/logic/SolidWaste.js @@ -1,37 +1,46 @@ /** * 鍥哄簾 */ +// 鍖哄垎涓嶅悓绫诲瀷 浣跨敤涓嶅悓img +const defaultImg = '/assets/images/map/solidwaste/voc.png' +const setting = '/assets/images/map/solidwaste/gf_green.png' + +const mapApi = require('../../../api/mapApi').default const AnimalService = require('../service/AnimalService').default -const AjaxUtils = require('../../../utils/AjaxUtils').default module.exports = function () { /** * 杩斿洖marker瀵硅薄鏁扮粍 * @param L leaflet瀵硅薄 */ - this.init = (layer, L) => { + this.init = async (layer, L) => { + // const SolidWasteIcon = this.SolidWasteIcon() this.animalService = new AnimalService({ L: L, - layer: layer, - LayerPopup: null + layer: layer }) - // AjaxUtils.get4JsonDataByUrl('http://10.246.162.140:8080/EPInterface/DataService/EPMapService.asmx/QueryStoragePlaceListByCompanyAndName', { - // AjaxUtils.get4JsonDataByUrl('http://xearth.cn:3000/wasteSolid/getSolidWaste', { - AjaxUtils.get4JsonDataByUrl('http://localhost:8888/static/SolidWaste.json', { - companyId: 3900100145, - userCode: 'wenchun.deng', - name: '', - marginWarr: '', - longDayWarr: '' - }, function (res) { - const data = res.data.Result.DataInfo - for (let i = 0; i < data.length; i++) { - // 缁忕含搴� 浣嶇疆 - const positionX = data[i].Latitude - const positionY = data[i].Longitude - layer.addLayer(L.marker([positionX, positionY], {})) - } - }) + const res = await mapApi.getSolidWaste() + // 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 + + // 瀹氫箟绫诲瀷 鐢ㄦ潵鍖哄垎鏁版嵁鐨勪笉鍚� + const judgeValue = data[i].StorageQty + var iconUrl = this.differentTypes(judgeValue) + + const marker = L.marker.magic([positionX, positionY], { + icon: L.icon({ + iconUrl: iconUrl, + iconSize: [50, 50], + iconAnchor: [25, 25] + }) + }) + + layer.addLayer(marker) + } } this.bindTooltip = (layer) => { @@ -41,8 +50,18 @@ this.clickListener = (e) => { this.animalService.pulseEffect(e.latlng) console.log(e) - console.log(this.PublicBounced) - // return this.PublicBounced.$el + return this.PublicBounced.$el + } + + // 涓嶅悓绫诲瀷鍥剧墖灏佽 + this.differentTypes = (judgeValue) => { + var effectOfChange + if (judgeValue === 1) { + effectOfChange = defaultImg + } else { + effectOfChange = setting + } + return effectOfChange } // 鍥哄簾鐐瑰嚮杩涜鐨� 鍐呭鐨勮缃� // SetSolidWasteContent (config, containerPopup) { -- Gitblit v1.8.0