@@ -160,6 +160,28 @@ export const LEGEND_STYLE_TYPES = {
160160 IMAGE : 'image' ,
161161 STYLE : 'style'
162162} ;
163+
164+ /**
165+ * 按地图版本创建 Sprite 加载处理函数,供 WebMap 和外部 WebApp 共用。
166+ * @param {string } mapVersion 地图版本号。
167+ * @returns {Function|undefined } 旧版地图返回线符号处理函数,新版地图不需要额外处理。
168+ */
169+ export function createSpriteLoadHandler ( mapVersion ) {
170+ const [ major , minor , patch ] = typeof mapVersion === 'string' ? mapVersion . split ( '.' ) . map ( Number ) : [ ] ;
171+ // 3.3.7 及以前的地图线符号需要垂直翻转;新版本由地图数据自身保证方向。
172+ if ( major > 3 || ( major === 3 && minor > 3 ) || ( major === 3 && minor === 3 && patch > 7 ) ) {
173+ return ;
174+ }
175+ return ( id , imageData , width , height ) => {
176+ // 翻转所有 line- 开头的图案
177+ if ( id && id . startsWith ( 'line-' ) ) {
178+ return flipImageVertically ( imageData , width , height ) ;
179+ }
180+
181+ return null ;
182+ } ;
183+ }
184+
163185export function createWebMapV3Extending ( SuperClass , { MapManager, mapRepo, crsManager, l7LayerUtil, webMapService } ) {
164186 return class WebMapV3 extends SuperClass {
165187 constructor ( mapId , options , mapOptions = { } ) {
@@ -319,20 +341,7 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
319341 }
320342
321343 _getSpriteLoad ( ) {
322- const version = this . _mapInfo && this . _mapInfo . version ;
323- const [ major , minor , patch ] = typeof version === 'string' ? version . split ( '.' ) . map ( Number ) : [ ] ;
324- // 3.3.7 及以前的地图线符号需要垂直翻转;新版本由地图数据自身保证方向。
325- if ( major > 3 || ( major === 3 && minor > 3 ) || ( major === 3 && minor === 3 && patch > 7 ) ) {
326- return ;
327- }
328- return ( id , imageData , width , height ) => {
329- // 翻转所有 line- 开头的图案
330- if ( id && id . startsWith ( 'line-' ) ) {
331- return flipImageVertically ( imageData , width , height ) ;
332- }
333-
334- return null ;
335- } ;
344+ return createSpriteLoadHandler ( this . _mapInfo && this . _mapInfo . version ) ;
336345 }
337346
338347 _getTransformRequest ( ) {
0 commit comments