@@ -1082,20 +1082,23 @@ export class WebMap extends ol.Observable {
10821082 this . layers = layers ;
10831083 layers . forEach ( function ( layer , index ) {
10841084 //加上底图的index
1085- let layerIndex = index + 1 ;
1086- if ( ( layer . dataSource && layer . dataSource . serverId ) || layer . layerType === "MARKER" || layer . layerType === 'HOSTED_TILE' ) {
1085+ let layerIndex = index + 1 ,
1086+ dataSource = layer . dataSource ,
1087+ isSampleData = dataSource && dataSource . type === "SAMPLE_DATA" && ! ! dataSource . name ; //SAMPLE_DATA是本地示例数据
1088+
1089+ if ( ( dataSource && dataSource . serverId ) || layer . layerType === "MARKER" || layer . layerType === 'HOSTED_TILE' || isSampleData ) {
10871090 //数据存储到iportal上了
10881091 let dataSource = layer . dataSource ,
10891092 serverId = dataSource ? dataSource . serverId : layer . serverId ;
1090- if ( ! serverId ) {
1093+ if ( ! serverId && ! isSampleData ) {
10911094 that . addLayer ( layer , null , layerIndex ) ;
10921095 that . layerAdded ++ ;
10931096 that . sendMapToUser ( len ) ;
10941097 return ;
10951098 }
1096- if ( ( layer . layerType === "MARKER" ) || ( dataSource && ( ! dataSource . accessType || dataSource . accessType === 'DIRECT' ) ) ) {
1099+ if ( ( layer . layerType === "MARKER" ) || ( dataSource && ( ! dataSource . accessType || dataSource . accessType === 'DIRECT' ) ) || isSampleData ) {
10971100 //原来二进制文件
1098- let url = `${ that . server } web/datas/${ serverId } /content.json?pageSize=9999999¤tPage=1` ;
1101+ let url = isSampleData ? ` ${ that . server } apps/dataviz/libs/sample-datas/ ${ dataSource . name } .json` : `${ that . server } web/datas/${ serverId } /content.json?pageSize=9999999¤tPage=1` ;
10991102 url = that . getRequestUrl ( url ) ;
11001103 FetchRequest . get ( url , null , {
11011104 withCredentials : this . withCredentials
@@ -1111,7 +1114,7 @@ export class WebMap extends ol.Observable {
11111114 }
11121115 if ( data && data . type ) {
11131116 if ( data . type === "JSON" || data . type === "GEOJSON" ) {
1114- data . content = JSON . parse ( data . content ) ;
1117+ data . content = data . content . type ? data . content : JSON . parse ( data . content ) ;
11151118 features = that . geojsonToFeature ( data . content , layer ) ;
11161119 } else if ( data . type === 'EXCEL' || data . type === 'CSV' ) {
11171120 features = that . excelData2Feature ( data . content , layer ) ;
0 commit comments