[OpenLayers-Users] proj4js/projection question

Dejung Gewissler dejung.gewissler at oit.state.nj.us
Fri Jan 25 12:36:03 EST 2008


Hi All-

My base layers are in NJ State Plane (EPSG:102711) and I would like a 
custom click handler to alert the coordinates in DD ("EPSG:4326").  The 
alert happens with the state plane coords and not them reprojected. 
Here's what I've done so far (perhaps it is not all necessary?):

- added to head     <script type="text/javascript" 
src="proj4js/lib/proj4js-compressed.js"></script>
- added the following to the click handler:
    var sourceProj = new Proj4js.Proj(map.getProjectionObject());
    var destProj = new Proj4js.Proj("EPSG:4326");
    var lonlat = map.getLonLatFromViewPortPx(e.xy);
    var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
    OpenLayers.Projection.transform(point, sourceProj, destProj);
    alert(point.x +" "+ point.y);

I am also getting an error in Firebug that it can't find 
http://127.0.0.1/ol/lib/defs/EPSG102711.js
I guess you need to have a custom js file for each projection??? If so, 
how do I create one?

If there is an easier way to do this, I am all ears!

Thanks,
Dejung



More information about the Users mailing list