Version 2 (modified by 16 years ago) ( diff ) | ,
---|
User Guide
Using Proj4js is a matter of including the library in your page, creating source and destination Proj objects, transforming point coordinates.
<script src="lib/proj4js-combined.js"></script> //adjust the path for your server … //somewhere in your JavaScript code where you need this var source = new Proj4js.Proj(‘EPSG:4236’); //source coordinates will be in Longitude/Latitude var dest = new Proj4js.Proj(‘EPSG:27563’); //destination coordinates in LCC, south of France var p = new Proj4js.Point(-76.0,45.0); //any object will do as long as it has 'x' and 'y' properties Proj4js.transform(source, dest, p); //do the transformation. x and y are modified in place //p.x and p.y are now EPSG:27563 easting and northing in meters …
Proj4js.Proj constructor
Every Proj object must be initialized with the parameters of the CRS to be used. Proj4js uses the same initialization parameters that PROJ4 uses [link].
The argument to the constructor is a key in the Proj4js.defs initialization parameters object.
Proj4js.defs["EPSG:27563"]="+title=LAMB sud france +proj=lcc +lat_1=44.1 +lat_0=44.1 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m";
If you know the projections to be used in your application
The Proj4js.defs value must be defined before the constructor is called. You can define these via the script tag (see examples in the lib/defs directory) or anywhere else in your application.
<script src="lib/defs/EPSG27563.js"></script >
Using dynamic lookup of initialization parameters
set libPath set proxy spatialreference.org