@@ -40,7 +40,7 @@ export class WebMap extends mapboxgl.Evented {
40
40
* @description 创建地图。
41
41
*/
42
42
_createMap ( ) {
43
- let { name, crs, center = new mapboxgl . LngLat ( 0 , 0 ) , zoom = 0 , bearing = 0 , pitch = 0 , minzoom, maxzoom } = this . _mapInfo ;
43
+ let { name, crs, center = new mapboxgl . LngLat ( 0 , 0 ) , zoom = 0 , bearing = 0 , pitch = 0 , minzoom, maxzoom, sprite } = this . _mapInfo ;
44
44
if ( this . _mapInfo . center && crs === 'EPSG:3857' ) {
45
45
center = Util . unproject ( center ) ;
46
46
}
@@ -52,6 +52,7 @@ export class WebMap extends mapboxgl.Evented {
52
52
center,
53
53
zoom,
54
54
style : {
55
+ sprite,
55
56
name,
56
57
version : 8 ,
57
58
sources : { } ,
@@ -86,11 +87,8 @@ export class WebMap extends mapboxgl.Evented {
86
87
description : relatedInfo . description
87
88
} ;
88
89
this . _mapResourceInfo = JSON . parse ( relatedInfo . projectInfo ) ;
89
- this . _createMapRelatedInfo ( ) . then ( res => {
90
- if ( res ) {
91
- this . _addLayersToMap ( ) ;
92
- }
93
- } ) ;
90
+ this . _createMapRelatedInfo ( ) ;
91
+ this . _addLayersToMap ( ) ;
94
92
} ) ;
95
93
}
96
94
@@ -104,31 +102,14 @@ export class WebMap extends mapboxgl.Evented {
104
102
for ( let key in glyphs ) {
105
103
this . map . style . addGlyphs ( key , glyphs [ key ] ) ;
106
104
}
107
- for ( let key in sprite ) {
108
- this . map . style . addSprite ( key , sprite [ key ] ) ;
109
- }
110
- // 添加地图图片资源
111
- const { images } = this . _mapResourceInfo ;
112
- const loadImagePromises = images . map ( ( { url, id } ) => {
113
- return new Promise ( ( resolve , reject ) => {
114
- this . map . loadImage ( url , ( error , image ) => {
115
- if ( error ) {
116
- reject ( error ) ;
117
- return ;
118
- }
119
- ! this . map . hasImage ( id ) && this . map . addImage ( id , image , { sdf : true } ) ;
120
- resolve ( url ) ;
121
- } ) ;
122
- } ) ;
123
- } ) ;
124
- return Promise . all ( loadImagePromises )
125
- . then ( ( imagesAddToMap ) => {
126
- this . fire ( 'getlayerresourcesucceeded' , { images : imagesAddToMap } ) ;
127
- return imagesAddToMap ;
128
- } )
129
- . catch ( ( error ) => {
130
- this . fire ( 'getlayerresourcefailed' , { error } ) ;
131
- } ) ;
105
+ // if (typeof sprite === 'object') {
106
+ // for (let key in sprite) {
107
+ // this.map.style.addSprite(key, sprite[key]);
108
+ // }
109
+ // } else {
110
+ // this.map.style.sprite = sprite;
111
+ // this.map.setStyle(this.map.style);
112
+ // }
132
113
}
133
114
134
115
/**
0 commit comments