[OpenLayers-Users] Referencing Kamap a Tile
Ben Brehmer
bbrehmer at refractions.net
Thu Jan 25 20:36:08 EST 2007
Christopher Schmidt wrote:
> 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,
>
mmmm, yes that would work....and right clicking the tile is not quite
what I need :)
But what I want to do, is reference the top and left attributes of a
tile that is already loaded, with the reference being made from a click
event in the viewport (from which I can retrieve the pixel or lon/lat).
Thanks,
Ben
More information about the Users
mailing list