[OpenLayers-Users] proj4js/projection question
dejung.gewissler at oit.state.nj.us
Fri Jan 25 12:36:03 EST 2008
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 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
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!
More information about the Users