From dd5a3207b7821e6288c5992ce88ef09d3c28cbe3 Mon Sep 17 00:00:00 2001 From: qiwei Date: Thu, 29 Feb 2024 14:57:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20webmap=20=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mapboxgl/mapping/WebMap.js | 3 +-- src/mapboxgl/mapping/index.js | 1 + src/mapboxgl/mapping/webmap/v2/WebMap.js | 8 ++++---- src/mapboxgl/mapping/webmap/v3/WebMap.js | 2 -- src/mapboxgl/namespace.js | 3 ++- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/mapboxgl/mapping/WebMap.js b/src/mapboxgl/mapping/WebMap.js index 0e29f3206a..a0e00b0537 100644 --- a/src/mapboxgl/mapping/WebMap.js +++ b/src/mapboxgl/mapping/WebMap.js @@ -214,5 +214,4 @@ return this.webMapInstance; } } - - mapboxgl.supermap.WebMap = WebMap; + \ No newline at end of file diff --git a/src/mapboxgl/mapping/index.js b/src/mapboxgl/mapping/index.js index 2dd9b16deb..32c1d58b9f 100644 --- a/src/mapboxgl/mapping/index.js +++ b/src/mapboxgl/mapping/index.js @@ -1,2 +1,3 @@ export { WebMap } from './WebMap'; export { initMap } from './InitMap'; +export { WebMap as WebMapV3} from './webmap/v3/WebMap'; diff --git a/src/mapboxgl/mapping/webmap/v2/WebMap.js b/src/mapboxgl/mapping/webmap/v2/WebMap.js index 6d5c8dbf3d..2cf415c589 100644 --- a/src/mapboxgl/mapping/webmap/v2/WebMap.js +++ b/src/mapboxgl/mapping/webmap/v2/WebMap.js @@ -16,8 +16,8 @@ ColorsPickerUtil } from '@supermap/iclient-common'; import { Util } from '../../../core/Util'; - import convert from 'xml-js'; import canvg from 'canvg'; + import { XMLParser } from "fast-xml-parser"; const MB_SCALEDENOMINATOR_3857 = [ '559082264.0287178', @@ -324,9 +324,9 @@ const DEFAULT_WELLKNOWNSCALESET = ['GoogleCRS84Quad', 'GoogleMapsCompatible']; return response.text(); }) .then(capabilitiesText => { - let converts = convert ? convert : window.convert; - let tileMatrixSet = JSON.parse(converts.xml2json(capabilitiesText, { compact: true, spaces: 4 })) - .Capabilities.Contents.TileMatrixSet; + const parser = new XMLParser({numberParseOptions:{hex : false, leadingZeros: false,eNotation: false},alwaysCreateTextNode: true, textNodeName: "_text"}); + let tileMatrixSet = parser.parse(capabilitiesText) + .Capabilities.Contents.TileMatrixSet; if (!Array.isArray(tileMatrixSet)) { tileMatrixSet = [tileMatrixSet]; } diff --git a/src/mapboxgl/mapping/webmap/v3/WebMap.js b/src/mapboxgl/mapping/webmap/v3/WebMap.js index c4c2dee64f..1feb3b3b64 100644 --- a/src/mapboxgl/mapping/webmap/v3/WebMap.js +++ b/src/mapboxgl/mapping/webmap/v3/WebMap.js @@ -267,5 +267,3 @@ export class WebMap extends mapboxgl.Evented { return layers; } } - -mapboxgl.supermap.WebMapV3 = WebMap; diff --git a/src/mapboxgl/namespace.js b/src/mapboxgl/namespace.js index ccd4003881..8ba8c96221 100644 --- a/src/mapboxgl/namespace.js +++ b/src/mapboxgl/namespace.js @@ -64,7 +64,7 @@ import { ChartView } from '@supermap/iclient-common/namespace'; -import { WebMap, initMap } from './mapping'; +import { WebMap, initMap, WebMapV3 } from './mapping'; import mapboxgl from 'mapbox-gl'; mapboxgl.supermap = {...SuperMap, ...mapboxgl.supermap}; @@ -75,6 +75,7 @@ mapboxgl.supermap.Logo = Logo; mapboxgl.supermap.Util = Util; mapboxgl.supermap.WebMap = WebMap; mapboxgl.supermap.initMap = initMap; +mapboxgl.supermap.WebMapV3 = WebMapV3; mapboxgl.supermap.Graphic = Graphic; mapboxgl.supermap.map.getDefaultVectorTileStyle = getDefaultVectorTileStyle; mapboxgl.supermap.map.setBackground = setBackground;