[OpenLayers-Users] Any examples using Proj4js and OpenLayers.Projection class?

Steve Lime Steve.Lime at dnr.state.mn.us
Thu Dec 20 10:45:20 EST 2007


Great, that explains the output I'm seeing, now to get the right numbers. Thanks Chris (and Mike)...

Steve

>>> On 12/20/2007 at 9:26 AM, in message <20071220152634.GB4172 at metacarta.com>,
Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Thu, Dec 20, 2007 at 02:47:42AM -0600, Steve Lime wrote:
>> I'm working with openlayers trunk trying to get some point projection to 
> work. Code like this:
>> 
>> <!-- pt src="scripts/openlayers/lib/OpenLayers.js"></scr -->
>> <!-- pt src="scripts/proj4js/lib/proj4js.js"></scr -->
>> <!-- pt src="scripts/proj4js/lib/projCode/stere.js"></scr -->
>> 
>> map = new OpenLayers.Map( $('map'), {maxExtent: new 
> OpenLayers.Bounds(-2668252.000000,-2707008.500000,2813685.000000,2774928.5000
> 00),
>>                                                  maxResolution: 10706.9082, 
> units: 'm', projection: 'EPSG:3031'} );
>> 
>> Proj4js.defs['EPSG:3031'] = '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 
> +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs'; // Antarctica 
> Polar Stereographic
>> var wgs84 = new	OpenLayers.Projection('WGS84');
>> 
>> var point = new OpenLayers.Geometry.Point(lon, lat);
>> OpenLayers.Projection.transform(point, wgs84, map.getProjection());
>> alert(point.x +" "+ point.y);
>> 
>> doesn't seem to work, the x, y members remain unchanged. Any ideas? 
> 
> map.getProjection() returns a string. map.getProjectionObject() is what
> you should be using. Passing a string instead of an object will cause
> the transform to not be performed. 
> 
> So, if you change map.getProjection() to map.getProjectionObject(),
> you'll probably get farther.
> 
> REgards,




More information about the Users mailing list