[OpenLayers-Users] proj4s and openlayers,
coordinates not projected
Robert Sanson
SansonR at asurequality.com
Mon Mar 16 16:16:45 EDT 2009
Hi Steve
This is what I do:
include EPSG files specifically as required:
<script src='OpenLayers.js'></script>
<script src="lib/proj4js-combined.js"></script>
<script src="lib/EPSG2193.js"></script>
<script src="lib/EPSG27200.js"></script>
<script src="lib/EPSG4326.js"></script>
<script type="text/javascript">
Later, I have code that retrieves the entered coordinates and converts:
var src = new OpenLayers.Projection('EPSG:4326');
var dest = new OpenLayers.Projection('EPSG:2193');
latitude = document.getElementById('lat').value;
longitude = document.getElementById('llong').value;
var markergeom = new OpenLayers.Geometry.Point(longitude,latitude);
//now in-place re-projection
OpenLayers.Projection.transform(markergeom, src, dest);
gpsx = markergeom.x;
gpsy = markergeom.y;
alert(gpsx + "," + gpsy);
Cheers,
Robert Sanson
>>> <Steve.Toutant at inspq.qc.ca> 17/03/2009 8:45 a.m. >>>
I created a simple html page where the user enter lat/long coordinates and the program returns the projected coord in EPSG 32198.
That works well, but if I insert the same code in a more complex program using openlayers, the coordinates are not projected. Here is the code I put just after map.setCenter()
var lon = -70.894826;
var lat = 48.329377;
var point = new OpenLayers.Geometry.Point(lon, lat);
var src = new OpenLayers.Projection('EPSG:4326');
OpenLayers.Projection.transform(point, src, map.getProjectionObject());
alert(point);
I included the script at the beginning of my program
<script src="../../proj4js/lib/proj4js-compressed.js"></script>
It seems that that the proj4js script is not found.
Any idea?
thanks
Steve
Click here ( https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== ) to report this email as spam.
------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------
This message has been scanned for malware by SurfControl plc. www.surfcontrol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090317/cdc77290/attachment.html
More information about the Users
mailing list