[OpenLayers-Users] Referencing Kamap a Tile
Christopher Schmidt
crschmidt at metacarta.com
Thu Jan 25 19:53:09 EST 2007
On Thu, Jan 25, 2007 at 04:36:05PM -0800, Ben Brehmer wrote:
> I have a Kamap Layer and I need to be able to reference the tile
> associated with a viewport pixel. I don't know if this is possible, but
> I want to retrieve the tile that lies underneath a certain pixel
> position within the viewport.
Right click? :)
More seriously, you can get the geographic location from
getLonLatFromPixel or something similar on the Map object, and then look
at the KaMap getURL function:
getURL: function (bounds) {
var mapRes = this.map.getResolution();
var scale = Math.round((this.map.getScale() * 10000)) / 10000;
var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w,
mapRes*this.tileSize.h);
var pX = Math.round(((bounds.left) / cellSize.w) *
this.tileSize.w);
var pY = -Math.round(((bounds.top) / cellSize.h) *
this.tileSize.h);
return this.getFullRequestString(
{ t: pY,
l: pX,
s: scale
});
},
Something like this ought used with px.lon, px.lat instead of
bounds.left, bounds.top might get you there, modulo some rounding
issues. Give it a shot?
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Users
mailing list