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

Bill Thoen bthoen at gisnet.com
Fri May 1 17:41:26 EDT 2009


Never mind, I think I got it. You don't use 'new' with these functions.

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 );
>    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
>
>   




More information about the Users mailing list