| | |
| | | import AjaxUtils from '@/utils/AjaxUtils' |
| | | import store from '@/store' |
| | | |
| | | var myRenderer = window.L.canvas() |
| | | class ServiceLayerHelper { |
| | | constructor (options) { |
| | | this.map = options.map |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | | }) |
| | | } |
| | |
| | | * 加载点数据 |
| | | * @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, |
| | |
| | | { |
| | | 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) { |