[OpenLayers-Users] Can't Convert Coordinates to Picels and Back Again

Christopher Schmidt crschmidt at metacarta.com
Fri May 1 23:59:30 EDT 2009


On Fri, May 01, 2009 at 03:10:47PM -0600, Bill Thoen wrote:
> Just trying to debug a box drawing routine, I got this error:
> 
> *this.getViewPortPxFromLonLat is not a function*
> 
> on Line #746 in file: http://mydomain.com/ol/OpenLayers.js
> 
> What I did to produce it was this (I'm just taking a valid coordinate, 
> converting it to a pixel and the trying to convert that pixel back to 
> the original coordinate):
>    var swpx = new map.getPixelFromLonLat( 2160077, 1575258 );
>    alert ( swpx.x + " " + swpx.y );
>    var sw = new map.getLonLatFromPixel( swpx );
              ^^^ Don't put a new here.

>    alert( sw.x +" " + sw.y );
> 
> I'm using Colorado State Plane (ESPG 2232) and the map seems to be 
> working just fine. The only weird problem is this happening deep in the 
> OL code out of my reach, and I don't know why it's happening. I'm using 
> OL 2.7.*
> *
> 
> What am I not doing right here? Although the function says LonLat, the 
> docs say x,y, so I assume that I can use these functions on projected 
> coordinates... but maybe not?
> 
> - Bill Thoen
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list