From 49b7797c391463387ec2dfa240ec086dd669c8f3 Mon Sep 17 00:00:00 2001 From: xiongjiaojiao Date: Mon, 15 Apr 2024 17:44:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90ut=E3=80=91fix=20ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-map/__tests__/WebMapViewModel.spec.js | 16 + .../web-map/control/legend/Legend.vue | 2 +- .../web-map/control/legend/LegendViewModel.js | 10 +- .../control/legend/__tests__/legend.spec.js | 41 +- .../control/legend/subs/StyleRenderer.vue | 49 -- test/unit/mocks/crs.js | 2 +- test/unit/mocks/data/WebMap/map_legends.json | 2 +- test/unit/mocks/data/WebMap/webmap3.json | 472 ++++++++++++++++++ test/unit/mocks/map.js | 2 +- test/unit/mocks/mapboxgl_iclient.js | 6 +- test/unit/mocks/mapboxgl_iclient_webmapv3.js | 151 ++++++ 11 files changed, 688 insertions(+), 65 deletions(-) create mode 100644 test/unit/mocks/data/WebMap/webmap3.json create mode 100644 test/unit/mocks/mapboxgl_iclient_webmapv3.js diff --git a/src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js b/src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js index 406eb263..62529269 100644 --- a/src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js +++ b/src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js @@ -28,6 +28,7 @@ import { } from 'vue-iclient/test/unit/mocks/data/CapabilitiesText.js'; import restmapLayer from 'vue-iclient/test/unit/mocks/data/WebMap/restmapLayer.json'; import dataflowLayer from 'vue-iclient/test/unit/mocks/data/WebMap/dataflowLayer.json'; +import webmap3Datas from 'vue-iclient/test/unit/mocks/data/WebMap/webmap3.json'; import dataflowLayerData from 'vue-iclient/test/unit/mocks/data/dataflowLayerData.json'; import mockFetch from 'vue-iclient/test/unit/mocks/FetchRequest'; import { webmap_MAPBOXSTYLE_Tile } from 'vue-iclient/test/unit/mocks/services'; @@ -1939,4 +1940,19 @@ describe('WebMapViewModel.spec', () => { await flushPromises(); jest.advanceTimersByTime(0); }); + + it('webmap3.0', async done => { + const fetchResource = { + 'https://localhost:8190/iportal/web/maps/249495311': webmap3Datas[1] + }; + mockFetch(fetchResource); + const viewModel = new WebMapViewModel(webmap3Datas[0]); + const callback = function () { + expect(viewModel.getAppreciableLayers().length).toBeLessThanOrEqual(webmap3Datas[0].layers.length); + done(); + }; + viewModel.on({ addlayerssucceeded: callback }); + await flushPromises(); + jest.advanceTimersByTime(0); + }); }); diff --git a/src/mapboxgl/web-map/control/legend/Legend.vue b/src/mapboxgl/web-map/control/legend/Legend.vue index 7ee30af1..fa12a018 100644 --- a/src/mapboxgl/web-map/control/legend/Legend.vue +++ b/src/mapboxgl/web-map/control/legend/Legend.vue @@ -162,7 +162,7 @@ export default { } }, loaded() { - this.viewModel = new LegendViewModel(this.webmap); + this.viewModel = new LegendViewModel(); this.initLegendList(); }, removed() { diff --git a/src/mapboxgl/web-map/control/legend/LegendViewModel.js b/src/mapboxgl/web-map/control/legend/LegendViewModel.js index eb3e26fd..5ae4c44e 100644 --- a/src/mapboxgl/web-map/control/legend/LegendViewModel.js +++ b/src/mapboxgl/web-map/control/legend/LegendViewModel.js @@ -7,14 +7,18 @@ import mapboxgl from 'vue-iclient/static/libs/mapboxgl/mapbox-gl-enhance'; * @extends mapboxgl.Evented */ class LegendViewModel extends mapboxgl.Evented { - constructor(webmap) { - super(webmap); + constructor() { + super(); + this.legendInfo = []; + } + + setMap({ webmap }) { this.webmap = webmap; this.legendInfo = this.webmap.getLegendInfo(); } getStyle(layerName) { - return this.legendInfo.filter((info) => { + return this.legendInfo.filter(info => { return info.layerId === layerName && info.styleGroup.length > 0; }); } diff --git a/src/mapboxgl/web-map/control/legend/__tests__/legend.spec.js b/src/mapboxgl/web-map/control/legend/__tests__/legend.spec.js index 1eedeaaa..d611993a 100644 --- a/src/mapboxgl/web-map/control/legend/__tests__/legend.spec.js +++ b/src/mapboxgl/web-map/control/legend/__tests__/legend.spec.js @@ -1,14 +1,32 @@ import { mount } from '@vue/test-utils'; import SmLegend from '../Legend.vue'; -import mockFetch from 'vue-iclient/test/unit/mocks/FetchRequest'; +import StyleRenderer from '../subs/StyleRenderer.vue'; +import ImageRenderer from '../subs/ImageRenderer.vue'; import mapLegends from 'vue-iclient/test/unit/mocks/data/WebMap/map_legends.json'; describe('Legend.vue', () => { let wrapper; let mapWrapper; - beforeEach(() => { - }); + document.getElementById = () => { + return { + getContext: () => ({ + arc: jest.fn(), + fill: jest.fn(), + fillRect: jest.fn(), + strokeRect: jest.fn(), + clearRect: jest.fn(), + beginPath: jest.fn(), + setLineDash: jest.fn(), + moveTo: jest.fn(), + lineTo: jest.fn(), + stroke: jest.fn(), + drawImage: jest.fn() + }) + }; + }; + + beforeEach(() => {}); afterEach(() => { jest.resetAllMocks(); @@ -20,19 +38,26 @@ describe('Legend.vue', () => { } }); - it('render default correctly', done => { + it('render default correctly', async done => { wrapper = mount(SmLegend, { propsData: { - layerNames: ['民航数据'], + layerNames: ['上海疫情点标注', '站点3', '未命名数据', '未命名数据(1)', '未命名数据(3)'], mapTarget: 'map' } }); - wrapper.vm.webmap = { - getLegendInfo: jest.fn(() => mapLegends) - } + const webmap = { + getLegendInfo: () => mapLegends + }; wrapper.vm.$options.loaded.call(wrapper.vm); + wrapper.vm.viewModel.setMap({ + webmap + }); + wrapper.vm.initLegendList(); + await wrapper.vm.$nextTick(); expect(wrapper.vm.legendList).not.toEqual({}); expect(wrapper.vm.mapTarget).toBe('map'); + expect(wrapper.find(StyleRenderer).exists()).toBeTruthy() + expect(wrapper.find(ImageRenderer).exists()).toBeTruthy() done(); }); }); diff --git a/src/mapboxgl/web-map/control/legend/subs/StyleRenderer.vue b/src/mapboxgl/web-map/control/legend/subs/StyleRenderer.vue index df6c86b7..41c7da32 100644 --- a/src/mapboxgl/web-map/control/legend/subs/StyleRenderer.vue +++ b/src/mapboxgl/web-map/control/legend/subs/StyleRenderer.vue @@ -125,24 +125,6 @@ export default { drawShape() { const canvas = document.getElementById(this.canvasId); const ctx = canvas.getContext('2d'); - // const { colors } = this.styleRendererData; - // if (colors) { - // const rect = { - // width: 214, - // height: 10 - // }; - // const gap = 5; - // canvas.width = rect.width + gap * 2; - // canvas.height = rect.height + gap * 6; - // const gradient = ctx.createLinearGradient(gap, 0, rect.width + gap, 0); - // gradient.addColorStop(0, colors[0].value); - // gradient.addColorStop(1, colors[1].value); - // ctx.beginPath(); - // ctx.fillStyle = gradient; - // ctx.fillRect(gap, 0, rect.width, rect.height); - // this.drawMinMaxShape({ ctx, gap, rect, colors }); - // return; - // } switch (this.shapeType) { case 'point': { const { fontSize, color, opacity } = this.styleRendererData; @@ -185,37 +167,6 @@ export default { } this.drawDashedLine(canvas, ctx); }, - drawMinMaxShape({ ctx, gap, rect, colors }) { - const width = gap * 2; - const height = gap + 3; - const outlineColor = '#d9d9d9'; - const arrowY = gap; - ctx.globalAlpha = 0.25; - // min - ctx.beginPath(); - ctx.moveTo(gap, rect.height); - ctx.lineTo(0, rect.height + arrowY); - ctx.lineTo(width, rect.height + arrowY); - ctx.fillStyle = outlineColor; - ctx.fill(); - ctx.fillStyle = colors[0].value; - ctx.fillRect(0, rect.height + arrowY, width, height); - ctx.strokeStyle = outlineColor; - ctx.strokeRect(0, rect.height + arrowY, width, height); - // max - ctx.moveTo(gap + rect.width, rect.height); - ctx.lineTo(rect.width, arrowY + rect.height); - ctx.lineTo(rect.width + gap * 2, arrowY + rect.height); - ctx.fillStyle = outlineColor; - ctx.fill(); - ctx.fillStyle = colors[1].value; - ctx.fillRect(rect.width, arrowY + rect.height, width, height); - ctx.strokeStyle = outlineColor; - ctx.strokeRect(rect.width, arrowY + rect.height, width, height); - ctx.globalAlpha = 1; - ctx.fillText(colors[0].key, 0, rect.height + arrowY + height + 12, 80); - ctx.fillText(colors[1].key, rect.width, arrowY + rect.height + height + 12, 80); - }, drawDashedLine(canvas, ctx) { const LEGEND_LINE_WIDTH = 100; const LINE_DASH_WIDTH = 1; diff --git a/test/unit/mocks/crs.js b/test/unit/mocks/crs.js index 32734002..1b3148fc 100644 --- a/test/unit/mocks/crs.js +++ b/test/unit/mocks/crs.js @@ -6,12 +6,12 @@ class CRS extends Evented { constructor(options) { super(); this.unit='m'; + this.epsgCode = options.epsgCode; } getExtent() { return [-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892]; } - u getOrigin() { return jest.fn()} getLngLatCenter() { return [0,0];} } diff --git a/test/unit/mocks/data/WebMap/map_legends.json b/test/unit/mocks/data/WebMap/map_legends.json index de59bb1e..33b95ed0 100644 --- a/test/unit/mocks/data/WebMap/map_legends.json +++ b/test/unit/mocks/data/WebMap/map_legends.json @@ -53,7 +53,7 @@ { "styleField": null, "style": { - "type": "style", + "type": "image", "shape": "POINT", "sprite": { "sdf": false, "pixelRatio": 1, "width": 9, "x": 0, "y": 0, "height": 9 }, "url": "http://localhost:8190/iportal/web/maps/168769956/sprites/sprite.png" diff --git a/test/unit/mocks/data/WebMap/webmap3.json b/test/unit/mocks/data/WebMap/webmap3.json new file mode 100644 index 00000000..5fbf863c --- /dev/null +++ b/test/unit/mocks/data/WebMap/webmap3.json @@ -0,0 +1,472 @@ +[ + { + "metadata": { + "layerCatalog": [ + { + "visible": true, + "parts": [ + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_384", + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_385", + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_386", + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_387", + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_388", + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_389", + "ms_composite_symbol_北京市轨道交通线路减_1712908151359_390" + ], + "id": "北京市轨道交通线路减", + "title": "北京市轨道交通线路减", + "type": "composite" + }, + { + "visible": true, + "id": "ms_站点3_1712735857741_21", + "title": "站点3", + "type": "basic" + }, + { + "visible": true, + "id": "站点3", + "title": "站点3", + "type": "basic" + }, + { + "visible": true, + "id": "ms_站点3_1712735793051_16", + "title": "站点3", + "type": "basic" + }, + { + "visible": true, + "parts": ["ms_北京市_1712822459356_412"], + "id": "北京市", + "title": "北京市", + "type": "composite" + } + ] + }, + "sources": { + "ms_435608982_1712735745629_12": { + "tiles": [ + "http://localhost8190/iportal/services/../web/datas/435608982/structureddata/tiles/{z}/{x}/{y}.mvt?epsgCode=3857&returnedFieldNames=%5B%22smpid%22%2C%22parent%22%2C%22adcode%22%2C%22level%22%2C%22centroid%22%2C%22childrenNum%22%2C%22center%22%2C%22subFeatureIndex%22%2C%22name%22%2C%22acroutes%22%2C%22geometry%22%5D&geometryFieldName=geometry" + ], + "bounds": [115.423411, 39.442758, 117.514583, 41.0608], + "type": "vector" + }, + "CHINA_DARK": { + "tiles": [ + "https://maptiles.supermapol.com/iserver/services/map_China/rest/maps/China_Dark/tileimage.png?scale={scale}&x={x}&y={y}&width={width}&height={height}&transparent=true&redirect=false&cacheEnabled=true" + ], + "tileSize": 256, + "attribution": "", + "bounds": [-180, -90, 180, 90], + "type": "raster" + }, + "ms_1755873792_1712735857741_22": { + "tiles": [ + "http://localhost8190/iportal/services/../web/datas/1755873792/structureddata/tiles/{z}/{x}/{y}.mvt?epsgCode=3857&returnedFieldNames=%5B%22smpid%22%2C%221111%E6%A0%87%E5%87%86%E5%90%8D%E7%A7%B0%22%2C%22SmID%22%2C%22SmGeometrySize%22%2C%221111SmUserID%22%2C%22SmY%22%2C%22SmGeoPosition%22%2C%22SmX%22%2C%22SmLibTileID%22%2C%22geometry%22%5D&geometryFieldName=geometry" + ], + "bounds": [116.36331703990744, 39.89942692791154, 116.38141290077355, 39.9767738835847], + "type": "vector" + }, + "ms_aggregation_1755873792_1712735796586_18": { + "tiles": [ + "http://localhost8190/iportal/web/datas/1755873792/structureddata/aggregation.mvt?zxyFilter={z},{x},{y},3857&pixelGroupBy=%7B%22aggCellSize%22%3A1%2C%22aggCellUnit%22%3A%22PX%22%7D&aggType=AVG&aggField=smpid" + ], + "bounds": [116.36331703990744, 39.89942692791154, 116.38141290077355, 39.9767738835847], + "type": "vector" + }, + "ms_1755873792_1712735782349_15": { + "tiles": [ + "http://localhost8190/iportal/services/../web/datas/1755873792/structureddata/tiles/{z}/{x}/{y}.mvt?epsgCode=3857&returnedFieldNames=%5B%22smpid%22%2C%221111%E6%A0%87%E5%87%86%E5%90%8D%E7%A7%B0%22%2C%22SmID%22%2C%22SmGeometrySize%22%2C%221111SmUserID%22%2C%22SmY%22%2C%22SmGeoPosition%22%2C%22SmX%22%2C%22SmLibTileID%22%2C%22geometry%22%5D&geometryFieldName=geometry" + ], + "bounds": [116.36331703990744, 39.89942692791154, 116.38141290077355, 39.9767738835847], + "type": "vector" + }, + "ms_2111415064_1712736129943_152": { + "tiles": [ + "http://localhost8190/iportal/services/../web/datas/2111415064/structureddata/tiles/{z}/{x}/{y}.mvt?epsgCode=3857&returnedFieldNames=%5B%22smpid%22%2C%22%E7%BB%88%E7%82%B9y%22%2C%22SmID%22%2C%22%E6%A0%87%E5%87%86%E5%90%8D%E7%A7%B0%22%2C%22%E8%B5%B7%E7%82%B9x%22%2C%22%E8%B5%B7%E7%82%B9y%22%2C%22testID%22%2C%22%E7%BB%88%E7%82%B9x%22%2C%22geometry%22%5D&geometryFieldName=geometry" + ], + "bounds": [116.10214436813241, 39.72316247533395, 116.4357788812853, 40.088344539540586], + "type": "vector" + } + }, + "crs": "EPSG:3857", + "center": [116.32736256710167, 39.66154043577449], + "zoom": 6.625933619458134, + "glyphs": {}, + "version": "3.1.5", + "rootUrl": "http://localhost8190/iportal/", + "maxzoom": 12, + "name": "ms-点", + "viewExtent": [113.30172641245197, 42.03069981416064, 119.35299872174913, 37.20829050073619], + "layers": [ + { + "metadata": {}, + "maxzoom": 12, + "id": "CHINA_DARK", + "source": "CHINA_DARK", + "type": "raster", + "minzoom": 0 + }, + { + "filter": ["any", ["all", [">=", "smpid", 1], ["<", "smpid", 3.5]]], + "metadata": {}, + "paint": { + "fill-outline-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 16, "#3288BD"], + "fill-pattern": [ + "case", + ["all", [">=", ["to-number", ["get", "smpid"]], 1], ["<", ["to-number", ["get", "smpid"]], 3.5]], + "polygon-83040554", + "polygon-83040554" + ], + "fill-opacity": 0.9 + }, + "id": "北京市", + "source": "ms_435608982_1712735745629_12", + "source-layer": "435608982$geometry", + "type": "fill" + }, + { + "filter": ["all", ["none", ["all", [">=", "smpid", 1], ["<", "smpid", 3.5]]]], + "metadata": {}, + "paint": { + "fill-outline-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 16, "#3288BD"], + "fill-color": [ + "case", + ["all", [">=", ["to-number", ["get", "smpid"]], 3.5], ["<", ["to-number", ["get", "smpid"]], 6]], + "#826DBA", + ["all", [">=", ["to-number", ["get", "smpid"]], 6], ["<", ["to-number", ["get", "smpid"]], 8.5]], + "#826DBA", + ["all", [">=", ["to-number", ["get", "smpid"]], 8.5], ["<", ["to-number", ["get", "smpid"]], 11]], + "#826DBA", + ["all", [">=", ["to-number", ["get", "smpid"]], 11], ["<", ["to-number", ["get", "smpid"]], 13.5]], + "#826DBA", + ["all", [">=", ["to-number", ["get", "smpid"]], 13.5], ["<", ["to-number", ["get", "smpid"]], 16.1]], + "#826DBA", + "#826DBA" + ], + "fill-opacity": 0.9 + }, + "id": "ms_北京市_1712822459356_412", + "source": "ms_435608982_1712735745629_12", + "source-layer": "435608982$geometry", + "type": "fill" + }, + { + "layout": { + "visibility": "visible" + }, + "metadata": {}, + "paint": { + "heatmap-color": [ + "interpolate", + ["linear"], + ["heatmap-density"], + 0, + "rgba(0,0,0,0)", + 0.2, + "#0000ff", + 0.4, + "#00ffff", + 0.6, + "#00ff00", + 0.8, + "#ffff00", + 1, + "#ff0000" + ], + "heatmap-opacity": 1, + "heatmap-weight": ["get", "weight"], + "heatmap-radius": 20 + }, + "id": "ms_站点3_1712735793051_16", + "source": "ms_aggregation_1755873792_1712735796586_18", + "source-layer": "1755873792$geometry", + "type": "heatmap" + }, + { + "metadata": {}, + "paint": { + "circle-color": "#EE4D5A", + "circle-opacity": 0.9, + "circle-translate-anchor": "map", + "circle-radius": 4, + "circle-translate": [0, 0] + }, + "id": "站点3", + "source": "ms_1755873792_1712735782349_15", + "source-layer": "1755873792$geometry", + "type": "circle" + }, + { + "layout": { + "icon-allow-overlap": true, + "text-line-height": 1.2, + "visibility": "visible", + "text-field": "", + "text-anchor": "center", + "text-size": 16, + "text-allow-overlap": true, + "icon-size": 0.2, + "symbol-placement": "point", + "icon-image": [ + "match", + ["get", "smpid"], + 1, + "rectangle", + 2, + "circle", + 3, + "triangle", + 4, + "rectangle", + "rectangle" + ], + "icon-ignore-placement": false, + "text-font": ["Microsoft YaHei"], + "text-rotate": 0, + "text-transform": "none", + "text-justify": "center", + "text-letter-spacing": 0, + "text-max-width": 10, + "icon-anchor": "center", + "text-ignore-placement": false, + "icon-rotate": 0 + }, + "metadata": {}, + "paint": { + "icon-translate": [50, 0], + "text-halo-color": "#242424", + "text-translate-anchor": "map", + "icon-color": "rgba(0,255,228,1)", + "text-halo-blur": 2, + "icon-translate-anchor": "map", + "text-color": "#FFFFFF", + "text-halo-width": 1, + "icon-opacity": 0.9, + "text-opacity": 1, + "text-translate": [0, 0] + }, + "id": "ms_站点3_1712735857741_21", + "source": "ms_1755873792_1712735857741_22", + "source-layer": "1755873792$geometry", + "type": "symbol" + }, + { + "filter": ["==", "smpid", 1], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, -0.92, 3, -9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "北京市轨道交通线路减", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["==", "smpid", 1], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.92, 3, 9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_384", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["==", "smpid", 2], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, -0.92, 3, -9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_385", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["==", "smpid", 2], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.92, 3, 9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_386", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["==", "smpid", 3], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, -0.92, 3, -9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_387", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["==", "smpid", 3], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.92, 3, 9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_388", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["none", ["==", "smpid", 1], ["==", "smpid", 2], ["==", "smpid", 3]], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, -0.92, 3, -9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_389", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + }, + { + "filter": ["none", ["==", "smpid", 1], ["==", "smpid", 2], ["==", "smpid", 3]], + "layout": { + "line-cap": "round", + "line-join": "round" + }, + "metadata": {}, + "paint": { + "line-width": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.15, 3, 1.54], + "line-offset": ["interpolate", ["linear"], ["get", "smpid"], 1, 0.92, 3, 9.23], + "line-dasharray": [69.63, 29.84, 318.26, 0], + "line-color": ["interpolate", ["linear"], ["get", "smpid"], 1, "#D53E4F", 3, "#3288BD"] + }, + "id": "ms_composite_symbol_北京市轨道交通线路减_1712908151359_390", + "source": "ms_2111415064_1712736129943_152", + "source-layer": "2111415064$geometry", + "type": "line" + } + ], + "sprite": "http://localhost8190/iportal/web/maps/249495311/sprites/sprite", + "pitch": 0, + "minzoom": 0 + }, + { + "extent": { + "top": 37.20829050073619, + "left": 113.30172641245197, + "bottom": 42.03069981416064, + "leftBottom": { + "x": 113.30172641245197, + "y": 42.03069981416064 + }, + "right": 119.35299872174913, + "rightTop": { + "x": 119.35299872174913, + "y": 37.20829050073619 + } + }, + "controls": null, + "extentString": "{\"top\":37.20829050073619,\"left\":113.30172641245197,\"bottom\":42.03069981416064,\"leftBottom\":{\"x\":113.30172641245197,\"y\":42.03069981416064},\"right\":119.35299872174913,\"rightTop\":{\"x\":119.35299872174913,\"y\":37.20829050073619}}", + "description": "", + "verifyReason": null, + "units": null, + "title": "ms-点", + "resolution": 0, + "checkStatus": "SUCCESSFUL", + "projectInfo": "{\"images\":\"http://localhost:8190/iportal/web/maps/249495311/sprites/sprite\",\"catalogs\":[{\"visualization\":{\"renderer\":[{\"lineDasharray\":{\"type\":\"simple\",\"value\":[1,0]},\"color\":{\"field\":[\"smpid\"],\"defaultValue\":\"#ffffff\",\"values\":[{\"value\":\"#D53E4F\",\"key\":1},{\"value\":\"#3288BD\",\"key\":3}],\"ribbon\":[\"#D53E4F\",\"#FC8D59\",\"#FEE08B\",\"#FFFFBF\",\"#E6F598\",\"#99D594\",\"#3288BD\"],\"interpolateInfo\":{\"type\":\"linear\"},\"type\":\"unique\"},\"lineTranslateAnchor\":{\"type\":\"simple\",\"value\":\"map\"},\"lineMiterLimit\":{\"type\":\"simple\",\"value\":2},\"lineOffset\":{\"type\":\"simple\",\"value\":0},\"lineJoin\":{\"type\":\"simple\",\"value\":\"miter\"},\"lineRoundLimit\":{\"type\":\"simple\",\"value\":1.05},\"lineTranslate\":{\"type\":\"simple\",\"value\":[0,0]},\"styleRenderMode\":\"mapboxgl\",\"symbolsContent\":{\"field\":[\"smpid\"],\"defaultValue\":{\"symbolId\":\"line-83030269\",\"style\":[{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":-2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}},{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}}]},\"values\":[{\"value\":{\"symbolId\":\"line-83030269\",\"style\":[{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":-2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}},{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}}]},\"key\":1},{\"value\":{\"symbolId\":\"line-83030269\",\"style\":[{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":-2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}},{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}}]},\"key\":2},{\"value\":{\"symbolId\":\"line-83030269\",\"style\":[{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":-2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}},{\"layout\":{\"line-cap\":\"round\",\"line-join\":\"round\"},\"paint\":{\"line-width\":0.38,\"line-offset\":2.27,\"line-dasharray\":[69.63,29.84,318.26,0],\"line-color\":\"rgba(255, 0, 0, 1.00)\"}}]},\"key\":3}],\"interpolateInfo\":{\"type\":\"custom\"},\"type\":\"unique\"},\"lineGapWidth\":{\"type\":\"simple\",\"value\":0},\"lineCap\":{\"type\":\"simple\",\"value\":\"butt\"},\"width\":{\"field\":[\"smpid\"],\"defaultValue\":4.92,\"values\":[{\"value\":2,\"key\":1},{\"value\":20,\"key\":3}],\"interpolateInfo\":{\"type\":\"linear\"},\"type\":\"unique\"},\"opacity\":{\"type\":\"simple\"}}]},\"visible\":true,\"catalogType\":\"layer\",\"msDatasetId\":\"ms_datasetId_1712736126050_150\",\"bounds\":[116.10214436813241,39.72316247533395,116.4357788812853,40.088344539540586],\"showLegend\":true,\"id\":\"北京市轨道交通线路减\",\"popupInfo\":{\"elements\":[{\"fieldName\":\"smpid\",\"type\":\"FIELD\"},{\"fieldName\":\"终点y\",\"type\":\"FIELD\"},{\"fieldName\":\"SmID\",\"type\":\"FIELD\"},{\"fieldName\":\"标准名称\",\"type\":\"FIELD\"},{\"fieldName\":\"起点x\",\"type\":\"FIELD\"},{\"fieldName\":\"起点y\",\"type\":\"FIELD\"},{\"fieldName\":\"testID\",\"type\":\"FIELD\"},{\"fieldName\":\"终点x\",\"type\":\"FIELD\"},{\"fieldName\":\"geometry\",\"type\":\"FIELD\"}],\"title\":\"北京市轨道交通线路减\"},\"title\":\"北京市轨道交通线路减\",\"layerSourceType\":\"Data\",\"layersContent\":[\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_384\",\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_385\",\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_386\",\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_387\",\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_388\",\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_389\",\"ms_composite_symbol_北京市轨道交通线路减_1712908151359_390\"]},{\"visualization\":{\"renderer\":[{\"rotate\":{\"type\":\"simple\",\"value\":0},\"textLetterSpacing\":{\"type\":\"simple\",\"value\":0},\"textTranslate\":{\"type\":\"simple\",\"value\":[0,0]},\"color\":{\"type\":\"simple\",\"value\":\"rgba(0,255,228,1)\"},\"textZOffset\":{\"type\":\"simple\",\"value\":0},\"symbolPlacement\":{\"type\":\"simple\",\"value\":\"point\"},\"textAnchor\":{\"type\":\"simple\",\"value\":\"center\"},\"translate\":{\"type\":\"simple\",\"value\":[50,0]},\"textRotate\":{\"type\":\"simple\",\"value\":0},\"textField\":{\"type\":\"simple\",\"value\":\"\"},\"styleRenderMode\":\"mapboxgl\",\"textHaloBlur\":{\"type\":\"simple\",\"value\":2},\"transform\":{\"type\":\"simple\",\"value\":\"none\"},\"symbolsContent\":{\"field\":[\"smpid\"],\"defaultValue\":{\"symbolId\":\"rectangle\",\"style\":{\"layout\":{\"icon-image\":\"rectangle\"}}},\"values\":[{\"value\":{\"symbolId\":\"rectangle\",\"style\":{\"layout\":{\"icon-image\":\"rectangle\"}}},\"key\":1},{\"value\":{\"symbolId\":\"circle\",\"style\":{\"layout\":{\"icon-image\":\"circle\"}}},\"key\":2},{\"value\":{\"symbolId\":\"triangle\",\"style\":{\"layout\":{\"icon-image\":\"triangle\"}}},\"key\":3},{\"value\":{\"symbolId\":\"rectangle\",\"style\":{\"layout\":{\"icon-image\":\"rectangle\"}}},\"key\":4}],\"interpolateInfo\":{\"type\":\"custom\"},\"type\":\"unique\"},\"textTranslateAnchor\":{\"type\":\"simple\",\"value\":\"map\"},\"justify\":{\"type\":\"simple\",\"value\":\"center\"},\"ignorePlacement\":{\"type\":\"simple\",\"value\":false},\"textAllowOverlap\":{\"type\":\"simple\",\"value\":true},\"maxWidth\":{\"type\":\"simple\",\"value\":10},\"textSize\":{\"type\":\"simple\",\"value\":16},\"textHaloColor\":{\"type\":\"simple\",\"value\":\"#242424\"},\"textColor\":{\"type\":\"simple\",\"value\":\"#FFFFFF\"},\"size\":{\"type\":\"simple\",\"value\":20},\"allowOverlap\":{\"type\":\"simple\",\"value\":true},\"translateAnchor\":{\"type\":\"simple\",\"value\":\"map\"},\"anchor\":{\"type\":\"simple\",\"value\":\"center\"},\"textOpacity\":{\"type\":\"simple\",\"value\":1},\"textHaloWidth\":{\"type\":\"simple\",\"value\":1},\"lineHeight\":{\"type\":\"simple\",\"value\":1.2},\"textFont\":{\"type\":\"simple\",\"value\":[\"Microsoft YaHei\"]},\"textIgnorePlacement\":{\"type\":\"simple\",\"value\":false},\"opacity\":{\"type\":\"simple\",\"value\":0.9}}]},\"visible\":true,\"catalogType\":\"layer\",\"msDatasetId\":\"ms_datasetId_1712735782333_13\",\"bounds\":[116.36331703990744,39.89942692791154,116.38141290077355,39.9767738835847],\"id\":\"ms_站点3_1712735857741_21\",\"popupInfo\":{\"elements\":[{\"fieldName\":\"smpid\",\"type\":\"FIELD\"},{\"fieldName\":\"1111标准名称\",\"type\":\"FIELD\"},{\"fieldName\":\"SmID\",\"type\":\"FIELD\"},{\"fieldName\":\"SmGeometrySize\",\"type\":\"FIELD\"},{\"fieldName\":\"1111SmUserID\",\"type\":\"FIELD\"},{\"fieldName\":\"SmY\",\"type\":\"FIELD\"},{\"fieldName\":\"SmGeoPosition\",\"type\":\"FIELD\"},{\"fieldName\":\"SmX\",\"type\":\"FIELD\"},{\"fieldName\":\"SmLibTileID\",\"type\":\"FIELD\"},{\"fieldName\":\"geometry\",\"type\":\"FIELD\"}],\"title\":\"站点3\"},\"title\":\"站点3\",\"layerSourceType\":\"Data\"},{\"visualization\":{\"renderer\":[{\"symbolsContent\":{\"type\":\"simple\",\"value\":{\"symbolId\":\"circle\",\"style\":{\"layout\":{\"icon-image\":\"circle\"}}}},\"size\":{\"type\":\"simple\",\"value\":8},\"color\":{\"type\":\"simple\",\"value\":\"#EE4D5A\"},\"translateAnchor\":{\"type\":\"simple\",\"value\":\"map\"},\"opacity\":{\"type\":\"simple\",\"value\":0.9},\"translate\":{\"type\":\"simple\",\"value\":[0,0]},\"styleRenderMode\":\"mapboxgl\"}]},\"visible\":true,\"catalogType\":\"layer\",\"msDatasetId\":\"ms_datasetId_1712735782333_13\",\"bounds\":[116.36331703990744,39.89942692791154,116.38141290077355,39.9767738835847],\"id\":\"站点3\",\"popupInfo\":{\"elements\":[{\"fieldName\":\"smpid\",\"type\":\"FIELD\"},{\"fieldName\":\"1111标准名称\",\"type\":\"FIELD\"},{\"fieldName\":\"SmID\",\"type\":\"FIELD\"},{\"fieldName\":\"SmGeometrySize\",\"type\":\"FIELD\"},{\"fieldName\":\"1111SmUserID\",\"type\":\"FIELD\"},{\"fieldName\":\"SmY\",\"type\":\"FIELD\"},{\"fieldName\":\"SmGeoPosition\",\"type\":\"FIELD\"},{\"fieldName\":\"SmX\",\"type\":\"FIELD\"},{\"fieldName\":\"SmLibTileID\",\"type\":\"FIELD\"},{\"fieldName\":\"geometry\",\"type\":\"FIELD\"}],\"title\":\"站点3\"},\"title\":\"站点3\",\"layerSourceType\":\"Data\"},{\"visualization\":{\"renderer\":[{\"field\":\"smpid\",\"color\":[{\"color\":\"#0000ff\"},{\"color\":\"#00ffff\"},{\"color\":\"#00ff00\"},{\"color\":\"#ffff00\"},{\"color\":\"#ff0000\"}],\"radius\":20,\"opacity\":1,\"type\":\"heat\"}]},\"visible\":true,\"catalogType\":\"layer\",\"msDatasetId\":\"ms_datasetId_1712735782333_13\",\"bounds\":[116.36331703990744,39.89942692791154,116.38141290077355,39.9767738835847],\"id\":\"ms_站点3_1712735793051_16\",\"popupInfo\":{\"elements\":[{\"fieldName\":\"smpid\",\"type\":\"FIELD\"},{\"fieldName\":\"1111标准名称\",\"type\":\"FIELD\"},{\"fieldName\":\"SmID\",\"type\":\"FIELD\"},{\"fieldName\":\"SmGeometrySize\",\"type\":\"FIELD\"},{\"fieldName\":\"1111SmUserID\",\"type\":\"FIELD\"},{\"fieldName\":\"SmY\",\"type\":\"FIELD\"},{\"fieldName\":\"SmGeoPosition\",\"type\":\"FIELD\"},{\"fieldName\":\"SmX\",\"type\":\"FIELD\"},{\"fieldName\":\"SmLibTileID\",\"type\":\"FIELD\"},{\"fieldName\":\"geometry\",\"type\":\"FIELD\"}],\"title\":\"站点3\"},\"title\":\"站点3\",\"layerSourceType\":\"Data\"},{\"visualization\":{\"renderer\":[{\"fillExtrusionTranslateAnchor\":{\"type\":\"simple\",\"value\":\"map\"},\"fillExtrusionVerticalGradient\":{\"type\":\"simple\",\"value\":true},\"color\":{\"type\":\"simple\"},\"fillExtrusionBase\":{\"type\":\"simple\",\"value\":0},\"fillExtrusionBaseMultiple\":{\"type\":\"simple\"},\"styleRenderMode\":\"mapboxgl\",\"fillExtrusionHeightMultiple\":{\"type\":\"simple\"},\"symbolsContent\":{\"field\":[\"smpid\"],\"defaultValue\":{\"symbolId\":\"polygon-0\",\"style\":{\"paint\":{\"fill-color\":\"#826DBA\"}}},\"values\":[{\"start\":1,\"end\":3.5,\"value\":{\"symbolId\":\"polygon-83040554\",\"style\":{\"paint\":{\"fill-pattern\":\"polygon-83040554\"}}}},{\"start\":3.5,\"end\":6,\"value\":{\"symbolId\":\"polygon-0\",\"style\":{\"paint\":{\"fill-color\":\"#826DBA\"}}}},{\"start\":6,\"end\":8.5,\"value\":{\"symbolId\":\"polygon-0\",\"style\":{\"paint\":{\"fill-color\":\"#826DBA\"}}}},{\"start\":8.5,\"end\":11,\"value\":{\"symbolId\":\"polygon-0\",\"style\":{\"paint\":{\"fill-color\":\"#826DBA\"}}}},{\"start\":11,\"end\":13.5,\"value\":{\"symbolId\":\"polygon-0\",\"style\":{\"paint\":{\"fill-color\":\"#826DBA\"}}}},{\"start\":13.5,\"end\":16.1,\"value\":{\"symbolId\":\"polygon-0\",\"style\":{\"paint\":{\"fill-color\":\"#826DBA\"}}}}],\"type\":\"range\",\"segmentMethod\":\"EQUALINTERVAL\",\"segmentCount\":6},\"fillExtrusionTranslate\":{\"type\":\"simple\",\"value\":[0,0]},\"antialias\":{\"type\":\"simple\",\"value\":true},\"outlineColor\":{\"field\":[\"smpid\"],\"defaultValue\":\"#ffffff\",\"values\":[{\"value\":\"#D53E4F\",\"key\":1},{\"value\":\"#3288BD\",\"key\":16}],\"ribbon\":[\"#D53E4F\",\"#FC8D59\",\"#FEE08B\",\"#FFFFBF\",\"#E6F598\",\"#99D594\",\"#3288BD\"],\"interpolateInfo\":{\"type\":\"linear\"},\"type\":\"unique\"},\"opacity\":{\"type\":\"simple\",\"value\":0.9},\"fillExtrusionHeight\":{\"type\":\"simple\",\"value\":0}}]},\"visible\":true,\"catalogType\":\"layer\",\"msDatasetId\":\"ms_datasetId_1712735745613_10\",\"bounds\":[115.423411,39.442758,117.514583,41.0608],\"showLegend\":true,\"id\":\"北京市\",\"popupInfo\":{\"elements\":[{\"fieldName\":\"smpid\",\"type\":\"FIELD\"},{\"fieldName\":\"parent\",\"type\":\"FIELD\"},{\"fieldName\":\"adcode\",\"type\":\"FIELD\"},{\"fieldName\":\"level\",\"type\":\"FIELD\"},{\"fieldName\":\"centroid\",\"type\":\"FIELD\"},{\"fieldName\":\"childrenNum\",\"type\":\"FIELD\"},{\"fieldName\":\"center\",\"type\":\"FIELD\"},{\"fieldName\":\"subFeatureIndex\",\"type\":\"FIELD\"},{\"fieldName\":\"name\",\"type\":\"FIELD\"},{\"fieldName\":\"acroutes\",\"type\":\"FIELD\"},{\"fieldName\":\"geometry\",\"type\":\"FIELD\"}],\"title\":\"北京市\"},\"title\":\"北京市\",\"layerSourceType\":\"Data\",\"layersContent\":[\"ms_北京市_1712822459356_412\"]}],\"datas\":[{\"sourceType\":\"STRUCTURE_DATA\",\"datasets\":[{\"datasetTitle\":\"上海疫情点标注(1)\",\"msDatasetId\":\"ms_datasetId_1712731623855_7\",\"datasetId\":\"443715040\",\"geometryField\":\"geometry\"}],\"title\":\"上海疫情点标注(1)\"},{\"sourceType\":\"STRUCTURE_DATA\",\"datasets\":[{\"datasetTitle\":\"北京市\",\"msDatasetId\":\"ms_datasetId_1712735745613_10\",\"datasetId\":\"435608982\",\"geometryField\":\"geometry\"}],\"title\":\"北京市\"},{\"sourceType\":\"STRUCTURE_DATA\",\"datasets\":[{\"datasetTitle\":\"站点3\",\"msDatasetId\":\"ms_datasetId_1712735782333_13\",\"datasetId\":\"1755873792\",\"geometryField\":\"geometry\"}],\"title\":\"站点3\"},{\"sourceType\":\"STRUCTURE_DATA\",\"datasets\":[{\"datasetTitle\":\"未命名数据(1)\",\"msDatasetId\":\"ms_datasetId_1712736088320_147\",\"datasetId\":\"680165081\",\"geometryField\":\"geometry\"}],\"title\":\"未命名数据(1)\"},{\"sourceType\":\"STRUCTURE_DATA\",\"datasets\":[{\"datasetTitle\":\"北京市轨道交通线路减\",\"msDatasetId\":\"ms_datasetId_1712736126050_150\",\"datasetId\":\"2111415064\",\"geometryField\":\"geometry\"}],\"title\":\"北京市轨道交通线路减\"}],\"baseLayer\":{\"internetMapName\":\"CHINA_DARK\",\"type\":\"INTERNET_MAP\"},\"version\":\"3.0.3\"}", + "visitCount": 15, + "centerString": "{\"x\":116.32736256710167,\"y\":39.66154043577449}", + "epsgCode": 3857, + "nickname": "admin_123", + "layers": null, + "id": 249495311, + "searchSetting": null, + "thumbnail": "http://localhost:8190/iportal/resources/thumbnail/map/map249495311.png", + "level": 6, + "center": { + "x": 116.32736256710167, + "y": 39.66154043577449 + }, + "authorizeSetting": [ + { + "permissionType": "DELETE", + "aliasName": "admin_123", + "entityRoles": ["ADMIN", "SYSTEM"], + "entityType": "USER", + "entityName": "admin_123", + "entityId": null + }, + { + "permissionType": "READWRITE", + "aliasName": "GUEST", + "entityRoles": [], + "entityType": "USER", + "entityName": "GUEST", + "entityId": null + } + ], + "updateTime": 1712908603401, + "userName": "admin_123", + "tags": [], + "checkUser": null, + "checkUserNick": null, + "checkTime": null, + "sourceType": "MAPSTUDIO", + "createTime": 1712731634188, + "controlsString": "", + "isDefaultBottomMap": false, + "status": null, + "favoriteCount": 0 + } +] diff --git a/test/unit/mocks/map.js b/test/unit/mocks/map.js index a05d79e6..2087bedc 100644 --- a/test/unit/mocks/map.js +++ b/test/unit/mocks/map.js @@ -81,7 +81,7 @@ var Map = function (options) { var ne = new LngLat(-73.9397, 40.8002); var llb = new LngLatBounds(sw, ne); this.bounds = this.options.bounds || llb; - this.crs = new CRS(); + this.crs = new CRS({ epsgCode: this.options.crs }); try { this.center = this.options.center ? new LngLat(this.options.center.lng, this.options.center.lat) : new LngLat(0, 0); } catch (e) { diff --git a/test/unit/mocks/mapboxgl_iclient.js b/test/unit/mocks/mapboxgl_iclient.js index ffbaa7b2..115a7693 100644 --- a/test/unit/mocks/mapboxgl_iclient.js +++ b/test/unit/mocks/mapboxgl_iclient.js @@ -1,5 +1,9 @@ var supermap = require('./supermap_mapboxgl'); var mapboxgl = require('@mocks/mapboxgl').mapboxgl; module.exports.SuperMap = require('./supermap'); +var WebMapV3 = require('./mapboxgl_iclient_webmapv3'); -mapboxgl.supermap = supermap; +mapboxgl.supermap = { + ...supermap, + WebMapV3 +}; diff --git a/test/unit/mocks/mapboxgl_iclient_webmapv3.js b/test/unit/mocks/mapboxgl_iclient_webmapv3.js new file mode 100644 index 00000000..6a08e987 --- /dev/null +++ b/test/unit/mocks/mapboxgl_iclient_webmapv3.js @@ -0,0 +1,151 @@ +var Evented = require('mapbox-gl/src/util/evented'); +var { mapboxgl } = require('./mapboxgl'); + +class WebMapV3 extends Evented { + constructor(mapId, options, mapOptions) { + super(); + this.mapId = mapId; + this.options = options; + this.mapOptions = mapOptions; + this._mapResourceInfo = {}; + } + + initializeMap(mapInfo, map) { + this._mapInfo = mapInfo; + if (map) { + this.map = map; + this._initLayers(); + return; + } + let { + name, + crs, + center = new mapboxgl.LngLat(0, 0), + zoom = 0, + bearing = 0, + pitch = 0, + minzoom, + maxzoom, + sprite = '' + } = this._mapInfo; + center = this.mapOptions.center || center; + zoom = this.mapOptions.zoom || zoom; + bearing = this.mapOptions.bearing || bearing; + pitch = this.mapOptions.pitch || pitch; + // 初始化 map + const mapOptions = { + container: this.options.target || 'map', + crs, + center, + zoom, + style: { + sprite, + name, + version: 8, + sources: {}, + layers: [] + }, + minzoom, + maxzoom, + bearing, + pitch, + localIdeographFontFamily: '' + }; + this.map = new mapboxgl.Map(mapOptions); + this._sprite = sprite; + this.fire('mapinitialized', { map: this.map }); + this.map.on('load', () => { + this._initLayers(); + }); + } + + getLegendInfo() {} + + clean() {} + + _initLayers() { + if (this.map && this.map.getCRS && this.map.getCRS().epsgCode !== this._mapInfo.crs) { + this.fire('projectionisnotmatch'); + return; + } + if (typeof this.mapId !== 'string') { + this._addLayersToMap(); + return; + } + SuperMap.FetchRequest.get(`${this.options.server}web/maps/${this.mapId}`, null, { + withCredentials: this.options.withCredentials + }) + .then(response => response.json()) + .then(relatedInfo => { + this._mapResourceInfo = JSON.parse(relatedInfo.projectInfo); + this._addLayersToMap(); + }); + } + + _addLayersToMap() { + const { sources, layers } = this._mapInfo; + layers.forEach(layer => { + layer.source && !this.map.getSource(layer.source) && this.map.addSource(layer.source, sources[layer.source]); + this.map.addLayer(layer); + }); + this._appreciableLayers = this._generateLayers(); + this.fire('addlayerssucceeded', { + map: this.map, + mapparams: { + title: this._mapInfo.name, + description: '' + }, + layers: this._appreciableLayers + }); + } + + _generateLayers() { + const { catalogs = [] } = this._mapResourceInfo; + const originLayers = this._getLayerInfosFromCatalogs(catalogs); + const layers = originLayers.map((layer) => { + const { title } = layer; + const layerFromMapInfo = this._mapInfo.layers.find((item) => { + return item.id === layer.id; + }); + let dataType = ''; + let dataId = ''; + for (const data of this._mapResourceInfo.datas) { + const matchData = data.datasets.find((dataset) => dataset.msDatasetId === layer.msDatasetId); + if (matchData) { + dataType = data.sourceType; + dataId = matchData.datasetId; + break; + } + } + const overlayLayers = { + dataSource: { + serverId: dataId, + type: dataType + }, + layerID: layer.id, + layerType: layerFromMapInfo.type === 'raster' ? 'raster' : 'vector', + type: layerFromMapInfo.type, + name: title + }; + return overlayLayers; + }); + return layers; + } + + _getLayerInfosFromCatalogs(catalogs) { + const results = []; + for (let i = 0; i < catalogs.length; i++) { + const { catalogType, children, visible } = catalogs[i]; + if (catalogType === 'layer' && visible) { + results.push(catalogs[i]); + } + if (catalogType === 'group' && children && children.length > 0) { + const result = this._getLayerInfosFromCatalogs(children); + results.push(...result); + } + } + return results; + } +} + +module.exports = WebMapV3;