File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -107,12 +107,14 @@ export class WebMap extends Observable {
107
107
this . tiandituKey = options . tiandituKey ;
108
108
//计数叠加图层,处理过的数量(成功和失败都会计数)
109
109
this . layerAdded = 0 ;
110
+ this . layers = [ ] ;
110
111
this . events = new Events ( this , null , [ "updateDataflowFeature" ] , true ) ;
111
112
this . createMap ( options . mapSetting ) ;
112
113
this . createWebmap ( ) ;
113
114
}
114
115
115
116
/**
117
+ * @private
116
118
* @function ol.supermap.WebMap.prototype._removeBaseLayer
117
119
* @description 移除底图
118
120
*/
@@ -127,6 +129,7 @@ export class WebMap extends Observable {
127
129
}
128
130
129
131
/**
132
+ * @private
130
133
* @function ol.supermap.WebMap.prototype._removeLayers
131
134
* @description 移除叠加图层
132
135
*/
@@ -155,10 +158,11 @@ export class WebMap extends Observable {
155
158
}
156
159
157
160
/**
161
+ * @private
158
162
* @function ol.supermap.WebMap.prototype.clear
159
163
* @description 清空地图
160
164
*/
161
- clear ( ) {
165
+ _clear ( ) {
162
166
// 比例尺
163
167
this . scales = [ ] ;
164
168
// 分辨率
@@ -173,11 +177,12 @@ export class WebMap extends Observable {
173
177
}
174
178
175
179
/**
176
- * @function ol.supermap.WebMap.prototype.reRender
180
+ * @function ol.supermap.WebMap.prototype.refresh
181
+ * @version 10.1.0
177
182
* @description 重新渲染地图
178
183
*/
179
- reRender ( ) {
180
- this . clear ( ) ;
184
+ refresh ( ) {
185
+ this . _clear ( ) ;
181
186
this . createWebmap ( ) ;
182
187
}
183
188
Original file line number Diff line number Diff line change @@ -981,4 +981,28 @@ describe('openlayers_WebMap', () => {
981
981
} , 1000 )
982
982
} ) ;
983
983
984
+ it ( 'refresh' , ( done ) => {
985
+ let refresh = false ;
986
+ spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
987
+ if ( url . indexOf ( 'map.json' ) > - 1 ) {
988
+ var mapJson = refresh ? datavizWebMap_BAIDU : datavizWebMap_TIANDITU_VEC ;
989
+ return Promise . resolve ( new Response ( mapJson ) ) ;
990
+ }
991
+ return Promise . resolve ( ) ;
992
+ } ) ;
993
+ var datavizWebmap = new WebMap ( id , {
994
+ server : server
995
+ } ) ;
996
+
997
+ setTimeout ( ( ) => {
998
+ expect ( datavizWebmap . baseLayer . name ) . toEqual ( '天地图' ) ;
999
+ refresh = true ;
1000
+ datavizWebmap . refresh ( ) ;
1001
+ setTimeout ( ( ) => {
1002
+ expect ( datavizWebmap . baseLayer . name ) . toEqual ( '百度地图' ) ;
1003
+ done ( ) ;
1004
+ } , 1000 ) ;
1005
+ } , 1000 )
1006
+ } )
1007
+
984
1008
} ) ;
You can’t perform that action at this time.
0 commit comments