|
71 | 71 |
|
72 | 72 | __webpack_require__(2) |
73 | 73 |
|
74 | | - ol.supermap.Tile = function (options) { |
| 74 | + ol.supermap.TileSuperMapRest = function (options) { |
75 | 75 | if (options.url === undefined) { |
76 | 76 | return; |
77 | 77 | } |
78 | | - var tileGrid = options.tileGrid; |
79 | | - var height = tileGrid.tileSize === undefined ? 256 : tileGrid.tileSize[0]; |
80 | | - var width = tileGrid.tileSize === undefined ? 256 : tileGrid.tileSize[1]; |
81 | | - var layerUrl = options.url + "/image.png?redirect=false&width=" + width + "&height=" + height; |
| 78 | + var layerUrl = options.url + "/image.png?redirect=false"; |
82 | 79 | //为url添加安全认证信息片段 |
83 | 80 | if (SuperMap.Credential && SuperMap.Credential.CREDENTIAL) { |
84 | 81 | layerUrl += "&" + SuperMap.Credential.CREDENTIAL.getUrlParameters(); |
|
101 | 98 | if (options.layersID !== undefined) { |
102 | 99 | layerUrl += "&layersID=" + options.layersID; |
103 | 100 | } |
104 | | - var extent = tileGrid.extent_; |
105 | | - var origin = tileGrid.origin_; |
106 | | - var origins = tileGrid.origins_; |
107 | | - var resolutions = tileGrid.resolutions_; |
108 | | - |
109 | | - var tileUrlFunction = function (tileCoord, pixelRatio, projection) { |
110 | | - var z = tileCoord[0], x = tileCoord[1], y = tileCoord[2], left, bottom, right, top; |
111 | | - var tileOrigin = getTileOrigin(z); |
112 | | - left = tileOrigin[0] + (x * width * resolutions[z]); |
113 | | - bottom = tileOrigin[1] + (y * height * resolutions[z]); |
114 | | - right = tileOrigin[0] + ((x + 1) * width * resolutions[z]); |
115 | | - top = tileOrigin[1] + ((y + 1) * height * resolutions[z]); |
116 | | - return layerUrl + "&viewBounds=" + "{\"leftBottom\" : {\"x\":" + left + ",\"y\":" + bottom + "},\"rightTop\" : {\"x\":" + right + ",\"y\":" + top + "}}"; |
117 | | - } |
118 | | - |
119 | | - function getTileOrigin(z) { |
120 | | - if (extent) { |
121 | | - return [extent[0], extent[3]]; |
122 | | - } |
123 | | - if (origin) { |
124 | | - return origin; |
125 | | - } |
126 | | - if (origins && z) { |
127 | | - return origins[z]; |
128 | | - } |
| 101 | + function tileUrlFunction(tileCoord, pixelRatio, projection) { |
| 102 | + if (!this.tileGrid) { |
| 103 | + this.tileGrid = this.getTileGridForProjection(projection); |
| 104 | + } |
| 105 | + var tileExtent = this.tileGrid.getTileCoordExtent( |
| 106 | + tileCoord, this.tmpExtent_); |
| 107 | + var tileSize = ol.size.toSize( |
| 108 | + this.tileGrid.getTileSize(tileCoord[0]), this.tmpSize); |
| 109 | + return layerUrl + "&width=" + tileSize[0] + "&height=" + tileSize[1] + "&viewBounds=" + "{\"leftBottom\" : {\"x\":" + tileExtent[0] + ",\"y\":" + tileExtent[1] + "},\"rightTop\" : {\"x\":" + tileExtent[2] + ",\"y\":" + tileExtent[3] + "}}"; |
129 | 110 | } |
130 | 111 |
|
131 | 112 | ol.source.TileImage.call(this, { |
|
150 | 131 |
|
151 | 132 | }); |
152 | 133 | }; |
153 | | - ol.inherits(ol.supermap.Tile, ol.source.TileImage); |
154 | | - |
155 | | - ol.supermap.Tile.optionsFromMapJSON = function (url, mapJSONObj) { |
| 134 | + ol.inherits(ol.supermap.TileSuperMapRest, ol.source.TileImage); |
| 135 | + ol.supermap.TileSuperMapRest.optionsFromMapJSON = function (url, mapJSONObj) { |
156 | 136 | var options = {}; |
157 | 137 | options.url = url; |
158 | 138 | var extent = [mapJSONObj.bounds.left, mapJSONObj.bounds.bottom, mapJSONObj.bounds.right, mapJSONObj.bounds.top]; |
|
194 | 174 | return options; |
195 | 175 | } |
196 | 176 |
|
197 | | - module.exports = ol.supermap.Tile; |
| 177 | + module.exports = ol.supermap.TileSuperMapRest; |
198 | 178 |
|
199 | 179 | /***/ }, |
200 | 180 | /* 2 */ |
|
0 commit comments