[OpenLayers-Users] weird thing with projections

Vivien Deparday vivien.deparday at gmail.com
Sat Apr 18 12:34:36 EDT 2009


What happens is explained there: 
http://trac.osgeo.org/proj4js/wiki/UserGuide in the Dynamic lookup of 
initialization parameters section.
I found this very deceptive too: when proj4js don't find the file in 
path lib/defs, it will load it from spatialreference.org 
<http://spatialreference.org> but *asynchronously*, so that when your 
script call transform, the projection definition is not there yet. So 
you should check your path to the EPSG23031.js and proj4js.js files and 
maybe add the EPSG4326.js too. Another option is to wait for 
Proj4js.Proj.readyToUse flag to be true.

Cheers,

Vivien

toni hernández wrote:
> Hi,
>
> I need to reproject a point to a pre-defined projection 
> (Proj4js.defs["EPSG:23031"] = "+proj=utm +zone=31 +ellps=intl +units=m 
> +no_defs ";).
> The weird thing is that the projection is not working unless I insert 
> and alert("stop for a while") after the line p = new 
> OpenLayers.Projection('EPSG:23031');
>
> Without the stop alert the point is shown in 4326 projection.
> Isn't it weird?
>
> Any ideas.
> I'm lost.
>
>     <script src="../proj4js/lib/defs/EPSG23031.js"></script>
>     <script src="../proj4js/lib/proj4js.js"></script>
>     <script src="../lib/OpenLayers.js"></script>   
> <script type="text/javascript">
> function init()
> {
>            p = new OpenLayers.Projection('EPSG:23031');
> //alert("stop for a while");
>             var proj = new OpenLayers.Projection("EPSG:4326");
>             var point = new OpenLayers.LonLat(-71, 42);
>             alert(point.transform(proj, p));
> }
> ...
> </script>
> <body onload=init()">
> ....
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   




More information about the Users mailing list