Skip to content

Commit 9fbefa7

Browse files
committed
【feature】1)webmap对接DV的本地示例数据格式
1 parent 8a12a64 commit 9fbefa7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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&currentPage=1`;
1101+
let url = isSampleData ? `${that.server}apps/dataviz/libs/sample-datas/${dataSource.name}.json` : `${that.server}web/datas/${serverId}/content.json?pageSize=9999999&currentPage=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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy