[OpenLayers-Users] weird thing with projections
Andreas Hocevar
ahocevar at opengeo.org
Sat Apr 18 14:43:45 EDT 2009
Hi,
toni hernández wrote:
> 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>
Don't load the above.
> <script src="../proj4js/lib/proj4js.js"></script>
> <script src="../lib/OpenLayers.js"></script>
> <script type="text/javascript">
> function init()
> {
// Instead, add here:
Proj4js.defs["EPSG:23031"] = "+proj=utm +zone=31 +ellps=intl +units=m
+no_defs ";
> 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()">
> ....
>
Regards,
Andreas.
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list