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