Where is your bounds coming from? I would expect bounds to be in terms of your 
map projection. Whereas map.getLonLatFromPixel is used to convert a pixel 
location to a map coordinate.

Regards,
 
Robert

>>> Puneet Kishor <[email protected]> 3/11/2011 11:46 a.m. >>>

On Nov 2, 2011, at 4:37 PM, Puneet Kishor wrote:

> I am reusing the sample code from the Handler.Box documentation
> 
> var control = new OpenLayers.Control();
> OpenLayers.Util.extend(control, {
> draw: function () {
> // this Handler.Box will intercept the shift-mousedown
> // before Control.MouseDefault gets to see it
> this.box = new OpenLayers.Handler.Box(
> control,
> {done: this.notice},
> {keyMask: OpenLayers.Handler.MOD_SHIFT}
> );
> this.box.activate();
> },
> 
> notice: function (bounds) {
> OpenLayers.Console.userError("bounds: " + bounds);
> var bbox = bounds.transform(proj.google, proj.latlng).toBBOX();
> OpenLayers.Console.userError("bbox: " + bbox);
> }
> });
> 

I am doing something wrong here trying to convert pixels to lat lng

var bbox = bounds.toArray();
var p1 = map.getLonLatFromPixel(bbox[0]);
var str  = "Lat: " + p1.lat + " (Pixel.x:" + p1.x + ") Lon: " + p1.lon + " 
(Pixel.y:" + p1.y + ")\n";
alert(str);

produces the following alert

Lat: NaN (Pixel.x:undefined) Lon: NaN (Pixel.y:undefined)


--
Puneet Kishor_______________________________________________
Users mailing list
[email protected] 
http://lists.osgeo.org/mailman/listinfo/openlayers-users


This email and any attachments are confidential and intended solely for the 
addressee(s). If you are not the intended recipient, please notify us 
immediately and then delete this email from your system.

This message has been scanned for Malware and Viruses by Websense Hosted 
Security.
www.websense.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to