Ticket #482: kamap_tile_bounds.patch
| File kamap_tile_bounds.patch, 1.8 kB (added by tschaub, 2 years ago) |
|---|
-
KaMap.js
old new 50 50 */ 51 51 getURL: function (bounds) { 52 52 var mapRes = this.map.getResolution(); 53 var scale = Math.round((this.map.getScale() * 10000)) / 10000; 54 var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h); 55 var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w); 56 var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h); 53 var scale = Math.round((this.map.getScale() * 10000)) / 10000; 54 var pX = Math.round(bounds.left / mapRes); 55 var pY = -Math.round(bounds.top / mapRes); 57 56 return this.getFullRequestString( 58 57 { t: pY, 59 58 l: pX, … … 146 145 this.spiralTileLoad(); 147 146 148 147 }, 148 /** 149 * 150 * @param {OpenLayers.Pixel} viewPortPx The location in the viewport 151 * 152 * @returns The tile bounds for a layer given a pixel location 153 * @type OpenLayers.Bounds 154 */ 155 getTileBounds: function(viewPortPx) { 156 var resolution = this.getResolution(); 157 var tileMapWidth = resolution * this.tileSize.w; 158 var tileMapHeight = resolution * this.tileSize.h; 159 var mapPoint = this.getLonLatFromViewPortPx(viewPortPx); 160 var tileLeft = tileMapWidth * Math.floor(mapPoint.lon / tileMapWidth); 161 var tileBottom = tileMapHeight * Math.floor(mapPoint.lat / tileMapHeight); 162 return new OpenLayers.Bounds(tileLeft, tileBottom, 163 tileLeft + tileMapWidth, 164 tileBottom + tileMapHeight); 165 }, 149 166 150 167 /** @final @type String */ 151 168 CLASS_NAME: "OpenLayers.Layer.KaMap"
