File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -126,10 +126,24 @@ export var MapExtend = (function () {
126
126
) ;
127
127
} ;
128
128
129
- maplibregl . Map . prototype . setSymbol = function ( layerId , symbol ) {
129
+ mapboxgl . Map . prototype . setSymbol = function ( layerId , symbol ) {
130
130
this . symbolLayerManager ( 'mapbox' , this ) . setSymbol ( layerId , symbol ) ;
131
131
} ;
132
132
133
+ if ( ! ( mapboxgl . Map . prototype ) . setStyleBak ) {
134
+ ( mapboxgl . Map . prototype ) . setStyleBak = mapboxgl . Map . prototype . setStyle ;
135
+ mapboxgl . Map . prototype . setStyle = function ( style , options ) {
136
+ this . setStyleBak ( style , options ) ;
137
+ this . style . once ( 'style.load' , ( ) => {
138
+ const symbolLayers = style . layers . filter ( l => l . symbol ) ;
139
+ symbolLayers . forEach ( ( l ) => {
140
+ this . setSymbol ( l . id , l . symbol ) ;
141
+ } ) ;
142
+ } ) ;
143
+ return this ;
144
+ }
145
+ } ;
146
+
133
147
function addLayer ( layer , map ) {
134
148
layer . onAdd && layer . onAdd ( map ) ;
135
149
}
Original file line number Diff line number Diff line change 1
1
import MapboxSymbolLayerManager from "./MapboxSymbolLayerManager" ;
2
2
3
- export const SymbolLayerManager = ( ) => {
3
+ const SymbolLayerManager = ( ) => {
4
4
const result = { } ;
5
5
return ( type ) => {
6
6
if ( ! result [ type ] ) {
@@ -10,4 +10,5 @@ export const SymbolLayerManager = () => {
10
10
}
11
11
return result [ type ] ;
12
12
}
13
- }
13
+ }
14
+ export default SymbolLayerManager ;
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export function getSymbolPaintLayout(symbolInfo) {
24
24
paint : {
25
25
'icon-color' : symbolInfo . color || IMAGE_POINT_DEFAULT_VALUE . color ,
26
26
'icon-opacity' : symbolInfo . opacity || IMAGE_POINT_DEFAULT_VALUE . opacity ,
27
- 'icon-translate' : symbolInfo . translate || IMAGE_POINT_DEFAULT_VALUE . translate ,
27
+ 'icon-translate' : symbolInfo . translate || IMAGE_POINT_DEFAULT_VALUE . translate
28
28
} ,
29
29
layout : {
30
30
'icon-size' : symbolInfo . size || IMAGE_POINT_DEFAULT_VALUE . size ,
@@ -51,7 +51,7 @@ export function getCirclePaintLayout(symbolInfo) {
51
51
'circle-stroke-color' : symbolInfo . stroke || SIMPLE_POINT_DEFAULT_VALUE . stroke ,
52
52
'circle-stroke-width' : symbolInfo . strokeWidth || SIMPLE_POINT_DEFAULT_VALUE . strokeWidth ,
53
53
'circle-stroke-opacity' : symbolInfo . strokeOpacity || SIMPLE_POINT_DEFAULT_VALUE . strokeOpacity ,
54
- 'circle-translate' : symbolInfo . translate || SIMPLE_POINT_DEFAULT_VALUE . translate ,
54
+ 'circle-translate' : symbolInfo . translate || SIMPLE_POINT_DEFAULT_VALUE . translate
55
55
// 符号库暂未支持的属性
56
56
// 'circle-translate-anchor': symbolInfo.translateAnchor
57
57
} ,
You can’t perform that action at this time.
0 commit comments