[OpenLayers-Users] Is there an example of using layers with differing source projections.. ie using Proj4?

Mike Adair madair at dmsolutions.ca
Wed Feb 13 09:59:53 EST 2008


An example that doesn't do much but demonstrates how to include Proj4js 
and use the OpenLayers objects to do coordinate transformations:

<script src="../lib/OpenLayers.js" type="text/javascript"></script>
<script src="../lib/proj4js/proj4js-compressed.js" 
type="text/javascript"></script>

<script type="text/javascript">
Proj4js.defs["EPSG:3003"] = "+title=Gauss Boaga EPSG:3003 +proj=tmerc 
+lat_0=0 +lon_0=9 +k=0.999600 +x_0=1500000 +y_0=0 +ellps=intl +units=m  
+no_defs";

  function init() {
    var point = new OpenLayers.Geometry.Point(9.5, 30.0);
    var src = new OpenLayers.Projection('EPSG:4326');
    var dest = new OpenLayers.Projection('EPSG:3003');
    OpenLayers.Projection.transform(point, src, dest);
    alert('coordinates transformed:'+point.toString());
  }
  window.onload = init;
</script>

The point to be transformed is any object that has  .x and  .y properties.

Mike



Lance Dyas wrote:
> Mike Adair wrote:
>   
>> EPSG:3003 uses a tmerc projection and is supported by Proj4js.  Did you 
>> remember to include the Proj4js library with a script tag in your 
>> application?
>>
>> Mike
>>
>>     
>



More information about the Users mailing list