[OpenLayers-Users] proj4js/projection question

Mike Adair madair at dmsolutions.ca
Fri Jan 25 12:47:13 EST 2008


That error is normal and expected.  What happens is that proj4js first 
tries to load the projection definition from the local server and if it 
can't find it (that's the error you see) it will try to look it up from 
spatialreference.org.  However to do that you need to define a proxy 
script like Proj4js.proxyScript = 'proxy.cgi'; so that it can make the 
Ajax request to the other domain.

Alternatively, you can manually save the projection definition to a file 
and include that using a <script> tag similar to the other projection 
definition files:
http://spatialreference.org/ref/epsg/102711/proj4js/

Mike


Dejung Gewissler wrote:
> 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
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>   



More information about the Users mailing list