| | 437 | /** |
|---|
| | 438 | * |
|---|
| | 439 | * @param {OpenLayers.Pixel} viewPortPx The location in the viewport |
|---|
| | 440 | * |
|---|
| | 441 | * @returns The tile bounds for a layer given a pixel location |
|---|
| | 442 | * @type OpenLayers.Bounds |
|---|
| | 443 | */ |
|---|
| | 444 | getTileBounds: function(viewPortPx) { |
|---|
| | 445 | var maxExtent = this.map.getMaxExtent(); |
|---|
| | 446 | var resolution = this.getResolution(); |
|---|
| | 447 | var tileMapWidth = resolution * this.tileSize.w; |
|---|
| | 448 | var tileMapHeight = resolution * this.tileSize.h; |
|---|
| | 449 | var mapPoint = this.getLonLatFromViewPortPx(viewPortPx); |
|---|
| | 450 | var tileLeft = maxExtent.left + (tileMapWidth * |
|---|
| | 451 | Math.floor((mapPoint.lon - |
|---|
| | 452 | maxExtent.left) / |
|---|
| | 453 | tileMapWidth)); |
|---|
| | 454 | var tileBottom = maxExtent.bottom + (tileMapHeight * |
|---|
| | 455 | Math.floor((mapPoint.lat - |
|---|
| | 456 | maxExtent.bottom) / |
|---|
| | 457 | tileMapHeight)); |
|---|
| | 458 | return new OpenLayers.Bounds(tileLeft, tileBottom, |
|---|
| | 459 | tileLeft + tileMapWidth, |
|---|
| | 460 | tileBottom + tileMapHeight); |
|---|
| | 461 | }, |
|---|
| | 462 | |
|---|