Add a getTileBounds method to gridded layers. Thanks to crschmidt for the tests on this one. Committed with a few minor ndoc changes (closes 482).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -225,6 +225,28 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getTileBounds
|
||||
* Returns The tile bounds for a layer given a pixel location.
|
||||
*
|
||||
* Parameters:
|
||||
* viewPortPx - {<OpenLayers.Pixel>} The location in the viewport.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bounds>} Bounds of the tile at the given pixel location.
|
||||
*/
|
||||
getTileBounds: function(viewPortPx) {
|
||||
var resolution = this.getResolution();
|
||||
var tileMapWidth = resolution * this.tileSize.w;
|
||||
var tileMapHeight = resolution * this.tileSize.h;
|
||||
var mapPoint = this.getLonLatFromViewPortPx(viewPortPx);
|
||||
var tileLeft = tileMapWidth * Math.floor(mapPoint.lon / tileMapWidth);
|
||||
var tileBottom = tileMapHeight * Math.floor(mapPoint.lat / tileMapHeight);
|
||||
return new OpenLayers.Bounds(tileLeft, tileBottom,
|
||||
tileLeft + tileMapWidth,
|
||||
tileBottom + tileMapHeight);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Layer.KaMap"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user