Skip to content

Commit 9830780

Browse files
author
caoxinke
committed
修改OpenLayers对接iServer地图服务出图方式为tileImage出图。
1 parent 3c4a4a1 commit 9830780

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

dist/iclient9-openlayers.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10719,7 +10719,7 @@ ol.supermap.TileSuperMapRest = function (options) {
1071910719
html: 'Map Data <a href="http://support.supermap.com.cn/product/iServer.aspx">SuperMap iServer</a> with <a href="http://icltest.supermapol.com/">SuperMap iClient</a>'
1072010720
})
1072110721

10722-
var layerUrl = options.url + "/image.png?redirect=false";
10722+
var layerUrl = options.url + "/tileImage.png?redirect=false";
1072310723
options.serverType = options.serverType || SuperMap.ServerType.ISERVER;
1072410724
//为url添加安全认证信息片段
1072510725
layerUrl = appendCredential(layerUrl, options.serverType);
@@ -10774,14 +10774,25 @@ ol.supermap.TileSuperMapRest = function (options) {
1077410774
}
1077510775

1077610776
function tileUrlFunction(tileCoord, pixelRatio, projection) {
10777+
this.projection = projection;
1077710778
if (!this.tileGrid) {
1077810779
this.tileGrid = this.getTileGridForProjection(projection);
1077910780
}
10780-
var tileExtent = this.tileGrid.getTileCoordExtent(
10781-
tileCoord, this.tmpExtent_);
10782-
var tileSize = ol.size.toSize(
10783-
this.tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
10784-
return layerUrl + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&viewBounds=" + "{\"leftBottom\" : {\"x\":" + tileExtent[0] + ",\"y\":" + tileExtent[1] + "},\"rightTop\" : {\"x\":" + tileExtent[2] + ",\"y\":" + tileExtent[3] + "}}";
10781+
var z = tileCoord[0];
10782+
var x = tileCoord[1];
10783+
var y = -tileCoord[2] - 1;
10784+
var resolution = this.tileGrid.getResolution(z);
10785+
var dpi = 96;
10786+
var unit = projection.getUnits();
10787+
if (unit === 'degrees') {
10788+
unit = SuperMap.Unit.DEGREE;
10789+
}
10790+
if (unit === 'm') {
10791+
unit = SuperMap.Unit.METER;
10792+
}
10793+
var scale = ol.supermap.Util.resolutionToScale(resolution, dpi, unit);
10794+
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z, this.tmpSize));
10795+
return layerUrl + "&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale;
1078510796
}
1078610797

1078710798
ol.source.TileImage.call(this, {

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/openlayers/mapping/TileSuperMapRest.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ol.supermap.TileSuperMapRest = function (options) {
1111
html: 'Map Data <a href="http://support.supermap.com.cn/product/iServer.aspx">SuperMap iServer</a> with <a href="http://icltest.supermapol.com/">SuperMap iClient</a>'
1212
})
1313

14-
var layerUrl = options.url + "/image.png?redirect=false";
14+
var layerUrl = options.url + "/tileImage.png?redirect=false";
1515
options.serverType = options.serverType || SuperMap.ServerType.ISERVER;
1616
//为url添加安全认证信息片段
1717
layerUrl = appendCredential(layerUrl, options.serverType);
@@ -66,14 +66,25 @@ ol.supermap.TileSuperMapRest = function (options) {
6666
}
6767

6868
function tileUrlFunction(tileCoord, pixelRatio, projection) {
69+
this.projection = projection;
6970
if (!this.tileGrid) {
7071
this.tileGrid = this.getTileGridForProjection(projection);
7172
}
72-
var tileExtent = this.tileGrid.getTileCoordExtent(
73-
tileCoord, this.tmpExtent_);
74-
var tileSize = ol.size.toSize(
75-
this.tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
76-
return layerUrl + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&viewBounds=" + "{\"leftBottom\" : {\"x\":" + tileExtent[0] + ",\"y\":" + tileExtent[1] + "},\"rightTop\" : {\"x\":" + tileExtent[2] + ",\"y\":" + tileExtent[3] + "}}";
73+
var z = tileCoord[0];
74+
var x = tileCoord[1];
75+
var y = -tileCoord[2] - 1;
76+
var resolution = this.tileGrid.getResolution(z);
77+
var dpi = 96;
78+
var unit = projection.getUnits();
79+
if (unit === 'degrees') {
80+
unit = SuperMap.Unit.DEGREE;
81+
}
82+
if (unit === 'm') {
83+
unit = SuperMap.Unit.METER;
84+
}
85+
var scale = ol.supermap.Util.resolutionToScale(resolution, dpi, unit);
86+
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z, this.tmpSize));
87+
return layerUrl + "&x=" + x + "&y=" + y + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&scale=" + scale;
7788
}
7889

7990
ol.source.TileImage.call(this, {

0 commit comments

Comments
 (0)