File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -12,22 +12,25 @@ import '../core/Base';
12
12
export var MapExtend = function ( ) {
13
13
14
14
mapboxgl . Map . prototype . overlayLayersManager = { } ;
15
- mapboxgl . Map . prototype . addLayerBak = mapboxgl . Map . prototype . addLayer ;
16
- mapboxgl . Map . prototype . addLayer = function ( layer , before ) {
17
- if ( layer . source || layer . type === 'custom' || layer . type === "background" ) {
18
- this . addLayerBak ( layer , before ) ;
15
+ if ( mapboxgl . Map . prototype . addLayerBak === undefined ) {
16
+ mapboxgl . Map . prototype . addLayerBak = mapboxgl . Map . prototype . addLayer ;
17
+ mapboxgl . Map . prototype . addLayer = function ( layer , before ) {
18
+ if ( layer . source || layer . type === 'custom' || layer . type === 'background' ) {
19
+ this . addLayerBak ( layer , before ) ;
20
+ return this ;
21
+ }
22
+ if ( this . overlayLayersManager [ layer . id ] || this . style . _layers [ layer . id ] ) {
23
+ this . fire ( 'error' , {
24
+ error : new Error ( 'A layer with this id already exists.' )
25
+ } ) ;
26
+ return ;
27
+ }
28
+ addLayer ( layer , this ) ;
29
+ this . overlayLayersManager [ layer . id ] = layer ;
19
30
return this ;
20
- }
21
- if ( this . overlayLayersManager [ layer . id ] || this . style . _layers [ layer . id ] ) {
22
- this . fire ( 'error' , {
23
- error : new Error ( 'A layer with this id already exists.' )
24
- } ) ;
25
- return ;
26
- }
27
- addLayer ( layer , this ) ;
28
- this . overlayLayersManager [ layer . id ] = layer ;
29
- return this ;
30
- } ;
31
+ } ;
32
+ }
33
+
31
34
mapboxgl . Map . prototype . getLayer = function ( id ) {
32
35
if ( this . overlayLayersManager [ id ] ) {
33
36
return this . overlayLayersManager [ id ] ;
You can’t perform that action at this time.
0 commit comments