From 6cdcf30b52502fa2b7db21064c40b7193bf7e25f Mon Sep 17 00:00:00 2001 From: YANGDL <114714267@qq.com> Date: 星期四, 25 二月 2021 10:55:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/components/helpers/ServiceLayerHelper.js | 84 ++++++++++++++++++++++++++++++++---------- 1 files changed, 64 insertions(+), 20 deletions(-) diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js index 7bef7bd..cbfdedd 100644 --- a/src/components/helpers/ServiceLayerHelper.js +++ b/src/components/helpers/ServiceLayerHelper.js @@ -3,6 +3,7 @@ * 鍒涘缓鍥惧眰鐩稿叧鐨勭被 */ import AjaxUtils from '@/utils/AjaxUtils' +import { GEOM_TYPE } from '../../conf/Constants' class ServiceLayerHelper { constructor (options) { @@ -27,7 +28,7 @@ */ initServiceLayers (layerConfig) { this.layerConfig = layerConfig - this._loadLayers(layerConfig.mapConfig.Layers.LayerSewersLine) + this.loadLayers(layerConfig.mapConfig.Layers.LayerSewersLine) } /** @@ -35,7 +36,7 @@ * @param {*} mapConfig * @param {*} isAddToMap */ - _loadLayers (layerConfig, isAddToMap = true) { + loadLayers (layerConfig, isAddToMap = true) { console.debug('ServiceLayerHelper鍔犺浇鍙傛暟锛�', layerConfig) for (let i = 0, len = layerConfig.length; i < len; ++i) { const opt = layerConfig[i] @@ -64,35 +65,78 @@ var layer = layers[i] var matchValue = layer[matches[1]] var checked = layer.checked + var geomtype = layer.geomtype if (!checked) { continue } var newUrl = url.replace(this.regex, matchValue) var that = this AjaxUtils.GetDataAsynByUrl(newUrl, {}, function (res) { - // let geojsondata = L.geoJSON(test.features,{ - that.L.geoJSON(res.features, { - style: function (feature) { - return { - fill: true, - weight: 2, - fillColor: '#06cccc', - color: '#06cccc', - fillOpacity: 0.2, - opacity: 0.8, - dashArray: '10,4', - dashSpeed: -10 - } - }, - minZoom: 10 - }).bindPopup(function (layer) { - // return layer.feature.properties.linenumber - }).addTo(that.map) + switch (geomtype) { + case GEOM_TYPE.POINT : + that.loadPointGeojson(res) + break + case GEOM_TYPE.LINE : + that.loadLineGeojson(res) + break + case GEOM_TYPE.POLYGON : + break + default: + that.loadLineGeojson(res) + break + } }) } } /** + * 鍔犺浇鐐规暟鎹� + * @param res + */ + loadPointGeojson (res) { + this.L.geoJSON(res.features, { + pointToLayer: function (geoJsonPoint, latlng) { + return this.L.canvasMarker(latlng, + { + radius: 20, + prevLatlng: this.L.latLng(51.503, -0.09), // previous point + img: { + url: './images/beng.png', + size: [20, 20], + rotate: 90 + } + }) + } + }).bindPopup(function (layer) { + // return layer.feature.properties.linenumber + }).addTo(this.map) + } + + /** + * 鍔犺浇绾挎暟鎹� + * @param res + */ + loadLineGeojson (res) { + this.L.geoJSON(res.features, { + style: function (feature) { + return { + fill: true, + weight: 2, + fillColor: '#06cccc', + color: '#06cccc', + fillOpacity: 0.2, + opacity: 0.8, + dashArray: '10,4', + dashSpeed: -10 + } + }, + minZoom: 10 + }).bindPopup(function (layer) { + // return layer.feature.properties.linenumber + }).addTo(this.map) + } + + /** * 寰�鍦板浘涓姞鍏ヤ竴涓猈MTS鏈嶅姟 * @param {}} options * @param {*} isAddToMap -- Gitblit v1.8.0