On Nov 2, 2011, at 5:54 PM, Robert Sanson wrote: > Where is your bounds coming from?
Its coming from the code I gave below (pretty much the exact code I am using, lifted from the docs). See my original post. > 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. > Indeed, that is what I expected as well, which is why I was converting from google projection (my map display projection) to lat lng (the projection I want the coordinates in). Except, much to my surprise I discovered that bounds was returning pixels. Hence, my attempt to convert those pixels to lat lng directly, which failed as well. > 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
