From 1883c95da4b79da03365e8e0eea6b917e6cb4f10 Mon Sep 17 00:00:00 2001 From: 徐旺旺 <11530253@qq.com> Date: 星期五, 26 二月 2021 12:11:01 +0800 Subject: [PATCH] 修改图层控制 --- src/components/helpers/ServiceLayerHelper.js | 29 ++++++++++++++--------------- 1 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js index eb4eb9e..fa100b0 100644 --- a/src/components/helpers/ServiceLayerHelper.js +++ b/src/components/helpers/ServiceLayerHelper.js @@ -5,6 +5,7 @@ import AjaxUtils from '@/utils/AjaxUtils' import store from '@/store' +var myRenderer = window.L.canvas() class ServiceLayerHelper { constructor (options) { this.map = options.map @@ -69,16 +70,16 @@ } } - loadGeojsonLayer (url, layer) { + loadGeojsonLayer (url, item) { var matches = this.regex.exec(url) - var matchValue = layer[matches[1]] - var code = layer.code + var matchValue = item[matches[1]] + var code = item.code var newUrl = url.replace(this.regex, matchValue) var that = this if (!that.geojsonArray[code]) { AjaxUtils.GetDataAsynByUrl(newUrl, {}, function (res) { store.commit('setSewersDatas', res) - var layer = that.loadGeojson(res) + var layer = that.loadGeojson(res, item) that.geojsonArray[code] = layer }) } @@ -88,12 +89,10 @@ * 鍔犺浇鐐规暟鎹� * @param res */ - loadGeojson (res) { + loadGeojson (res, layer) { var that = this - const featureGroup = that.L.featureGroup([], { - attribution: { id: '123' } - }).addTo(that.map) - that.L.geoJSON(res.features, { + var icon = layer.icon + return that.L.geoJSON(res.features, { style: function (feature) { return { fill: true, @@ -111,16 +110,16 @@ { radius: 20, img: { - url: 'assets/images/map/marker-icon.png', + // url: 'assets/images/map/marker-icon.png', + url: '/assets/images/map/' + icon, size: [20, 20] } }) - } + }, + renderer: myRenderer }).bindPopup(function (layer) { - // return layer.feature.properties.linenumber - }).addTo(featureGroup) - featureGroup.bringToBack() - return featureGroup + return layer.feature.properties.linenumber + }).addTo(that.map) } removeLayer (item) { -- Gitblit v1.8.0