@@ -1082,20 +1082,23 @@ export class WebMap extends ol.Observable {
1082
1082
this . layers = layers ;
1083
1083
layers . forEach ( function ( layer , index ) {
1084
1084
//加上底图的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 ) {
1087
1090
//数据存储到iportal上了
1088
1091
let dataSource = layer . dataSource ,
1089
1092
serverId = dataSource ? dataSource . serverId : layer . serverId ;
1090
- if ( ! serverId ) {
1093
+ if ( ! serverId && ! isSampleData ) {
1091
1094
that . addLayer ( layer , null , layerIndex ) ;
1092
1095
that . layerAdded ++ ;
1093
1096
that . sendMapToUser ( len ) ;
1094
1097
return ;
1095
1098
}
1096
- if ( ( layer . layerType === "MARKER" ) || ( dataSource && ( ! dataSource . accessType || dataSource . accessType === 'DIRECT' ) ) ) {
1099
+ if ( ( layer . layerType === "MARKER" ) || ( dataSource && ( ! dataSource . accessType || dataSource . accessType === 'DIRECT' ) ) || isSampleData ) {
1097
1100
//原来二进制文件
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` ;
1099
1102
url = that . getRequestUrl ( url ) ;
1100
1103
FetchRequest . get ( url , null , {
1101
1104
withCredentials : this . withCredentials
@@ -1111,7 +1114,7 @@ export class WebMap extends ol.Observable {
1111
1114
}
1112
1115
if ( data && data . type ) {
1113
1116
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 ) ;
1115
1118
features = that . geojsonToFeature ( data . content , layer ) ;
1116
1119
} else if ( data . type === 'EXCEL' || data . type === 'CSV' ) {
1117
1120
features = that . excelData2Feature ( data . content , layer ) ;
0 commit comments