MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / getTileLayerExtentInfo

Method getTileLayerExtentInfo

src/openlayers/mapping/WebMap.js:1519–1570  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.getTileLayerExtentInfo * @description 获取rest map的图层参数。 * @param {Object} layerInfo - 图层信息。 * @param {boolean} isDynamic - 是否请求动态投影信息

(layerInfo, isDynamic = true)

Source from the content-addressed store, hash-verified

1517 * @param {boolean} isDynamic - 是否请求动态投影信息
1518 */
1519 getTileLayerExtentInfo(layerInfo, isDynamic = true) {
1520 let that = this,
1521 token,
1522 url = layerInfo.url.trim(),
1523 credential = layerInfo.credential,
1524 options = {
1525 withCredentials: that.isCredentail(url, layerInfo.proxy),
1526 withoutFormatSuffix: true
1527 };
1528 if (isDynamic) {
1529 let projection = {
1530 epsgCode: that.baseProjection.split(':')[1]
1531 };
1532 if (!that.isCustomProjection(that.baseProjection)) {
1533 // bug IE11 不会自动编码
1534 url += '.json?prjCoordSys=' + encodeURI(JSON.stringify(projection));
1535 }
1536 }
1537 if (credential) {
1538 url = `${url}&token=${encodeURI(credential.token)}`;
1539 token = credential.token;
1540 }
1541 url = this.handleJSONSuffix(url);
1542 return FetchRequest.get(that.getRequestUrl(url, layerInfo.proxy), null, options)
1543 .then(function (response) {
1544 return response.json();
1545 })
1546 .then(async (result) => {
1547 if (result.succeed === false) {
1548 return result;
1549 }
1550 let format = 'png';
1551 if (that.tileFormat === 'webp') {
1552 const isSupportWebp = await that.isSupportWebp(layerInfo.url, token, layerInfo.proxy);
1553 format = isSupportWebp ? 'webp' : 'png';
1554 }
1555 return {
1556 units: result.coordUnit && result.coordUnit.toLowerCase(),
1557 coordUnit: result.coordUnit,
1558 visibleScales: result.visibleScales,
1559 extent: [result.bounds.left, result.bounds.bottom, result.bounds.right, result.bounds.top],
1560 projection: `EPSG:${result.prjCoordSys.epsgCode}`,
1561 format
1562 };
1563 })
1564 .catch((error) => {
1565 return {
1566 succeed: false,
1567 error: error
1568 };
1569 });
1570 }
1571
1572 /**
1573 * @private

Callers 1

getTileLayerExtentMethod · 0.80

Calls 7

handleJSONSuffixMethod · 0.95
trimMethod · 0.80
isCredentailMethod · 0.80
isCustomProjectionMethod · 0.80
getRequestUrlMethod · 0.80
isSupportWebpMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected