[OpenLayers-Users] OpenLayers do not detect Proj4js
Robert Sanson
Robert.Sanson at asurequality.com
Thu Feb 6 16:35:38 PST 2014
Hi Juan
You are missing the .js file name in the first <script></script> block.
Here is some code that works for me:
<script src="lib/proj4js-compressed.js"></script>
<script src="lib/EPSG2193.js"></script>
<script src="lib/EPSG4326.js"></script>
<script src="OpenLayers.js"></script>
<script type="text/javascript">
var xys = map.getLonLatFromViewPortPx(e.xy);
easting = xys.lon;
northing = xys.lat;
var tempgeom = new OpenLayers.Geometry.Point(easting,northing);
//now re-projection to WGS84
var src = new OpenLayers.Projection('EPSG:2193');
var dest = new OpenLayers.Projection('EPSG:4326');
OpenLayers.Projection.transform(tempgeom, src, dest);
regards,
Robert
>>> "Juanma M. R." <juanma.mr at gmail.com> 7/02/2014 3:23 a.m. >>>
Dear list,
I am trying to reproject in client side using OpenLAyers but I have
problems to find how to make OpenLayers detecting Proj4js. The proj
The source code for including OpenLayers and Proj4js is:
<script TYPE="text/javascript" src="proj4js-2.1.0/dist/"></script>
> <script TYPE="text/javascript"
> src="OpenLayers-2.10/OpenLayers.js"></script>
The source code for reprojecting is:
olb = new OpenLayers.Bounds(b.minx,b.miny,b.maxx,b.maxy);
var srcprj = new OpenLayers.Projection("EPSG:23030");
>
var destprj = new OpenLayers.Projection("EPSG:900913"); //A definition of
>
newOlb = olb.transform(srcprj, destprj);
The OpenLayers.Projection method creates a Projection object but the proj
instance, the property of Projection type, is null in both cases. So I
imagine it is not capable of creating it. I have the documentation but
maybe I am missing something so obvious ... the final result is that the
coordinates of the new bounds are a copy of the original ones.
The other question is how to declare the "EPSG:900913". I have included a
file with the Proj4js.defs for each EPSG code to be included but when I add
the line to include this .js content it teels me that Proj4js is not an
object.
So, I am doing something wrong integrating the proj4js and OpenLayers.
Could anyone help me? Just pointing to the right docummentation to
configure OpenLayers with Proj4js (I have already tried copying proj4js in
the same folder as OpenLayers.js but t didn't work).
Cheers,
Juan Manuel Moreno Rivera.
This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system.
This message has been scanned for Malware and Viruses by Websense Hosted Security.
www.websense.com
More information about the Users
mailing list