Skip to content

Commit

Permalink
【fix】修复eslint问题 review by qiwei
Browse files Browse the repository at this point in the history
  • Loading branch information
shallowdream218 committed Oct 20, 2023
1 parent ee031af commit 4d3d3d6
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,18 @@ export default class WebMapViewModel extends WebMapBase {
wkt,
bounds,
bounds[2] > 180 ? 'meter' : 'degree'
)
);
mapboxgl.CRS.set(crs);
}

_getMapInfo(mapInfo, _taskID): void {
const { projection } = mapInfo;

let bounds, wkt;
this.baseProjection = toEpsgCode(projection);
let defaultWktValue = getProjection(this.baseProjection)
let defaultWktValue = getProjection(this.baseProjection);

if (defaultWktValue) {
wkt = defaultWktValue
wkt = defaultWktValue;
}
if (!mapboxgl.CRS.get(this.baseProjection)) {
if (mapInfo.baseLayer && mapInfo.baseLayer.layerType === 'MAPBOXSTYLE') {
Expand All @@ -316,48 +315,46 @@ export default class WebMapViewModel extends WebMapBase {
}
this.webMapService.getMapBoxStyle(url).then((res: any) => {
if (res && res.metadata && res.metadata.indexbounds) {
bounds = res.metadata.indexbounds
bounds = res.metadata.indexbounds;
} else {
bounds = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y]
bounds = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y];
}
this._defineProj4(projection);
this._setCRS(this.baseProjection, wkt, bounds)

this._setCRS(this.baseProjection, wkt, bounds);
this._loadLayers(mapInfo, _taskID);
})
});
} else if (mapInfo.baseLayer && mapInfo.baseLayer.layerType === 'TILE') {
//获取地图的wkt
// 获取地图的wkt
this.getEpsgCodeWKT(`${mapInfo.baseLayer.url}/prjCoordSys.wkt`, {
withoutFormatSuffix: true,
withCredentials: this.webMapService.handleWithCredentials('', mapInfo.baseLayer.url, false)
}).then(res => {
if (!wkt) {
wkt = res
wkt = res;
}
this.getBounds(`${mapInfo.baseLayer.url}.json`, {
withoutFormatSuffix: true,
withCredentials: this.webMapService.handleWithCredentials('', mapInfo.baseLayer.url, false)
}).then(res => {
if (res && res.bounds) {
bounds = [res.bounds.leftBottom.x, res.bounds.leftBottom.y, res.bounds.rightTop.x, res.bounds.rightTop.y]
bounds = [res.bounds.leftBottom.x, res.bounds.leftBottom.y, res.bounds.rightTop.x, res.bounds.rightTop.y];
} else {
bounds = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y]
bounds = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y];
}

this._defineProj4(wkt, projection);
this._setCRS(this.baseProjection, wkt, bounds)
this._setCRS(this.baseProjection, wkt, bounds);
this._loadLayers(mapInfo, _taskID);
})
})
});
});
} else {
// this._defineProj4(projection);
// this._loadLayers(mapInfo, _taskID);
throw Error(geti18n().t('webmap.crsNotSupport'));
}
} else {
this._defineProj4(projection);
bounds = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y]
this._setCRS(this.baseProjection, wkt, bounds)
bounds = [mapInfo.extent.leftBottom.x, mapInfo.extent.leftBottom.y, mapInfo.extent.rightTop.x, mapInfo.extent.rightTop.y];
this._setCRS(this.baseProjection, wkt, bounds);
this._loadLayers(mapInfo, _taskID);
}
}
Expand Down Expand Up @@ -2721,7 +2718,7 @@ export default class WebMapViewModel extends WebMapBase {
return epsgCode;
}

private FetchRequet(url: any, type: string, options: object) {
private _fetchRequest(url: any, type: string, options: Object) {
return SuperMap.FetchRequest.get(url, null, options).then(response => {
return response[type]();
})
Expand All @@ -2737,15 +2734,14 @@ export default class WebMapViewModel extends WebMapBase {
if (!projectionUrl) {
return;
}
return this.FetchRequet(projectionUrl, 'text', options)
return this._fetchRequest(projectionUrl, 'text', options);
}


private getBounds(baseUrl, options) {
if (!baseUrl) {
return;
}
return this.FetchRequet(baseUrl, 'json', options)
return this._fetchRequest(baseUrl, 'json', options);
}

private _addLayer(layerInfo) {
Expand Down

0 comments on commit 4d3d3d6

Please sign in to comment.