Changes between Version 1 and Version 2 of UserGuide
- Timestamp:
- Jun 4, 2008, 8:09:58 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UserGuide
v1 v2 3 3 Using Proj4js is a matter of including the library in your page, creating source and destination Proj objects, transforming point coordinates. 4 4 5 6 5 {{{ 7 6 8 <script src="lib/proj4js-combined.js"></script> 7 <script src="lib/proj4js-combined.js"></script> //adjust the path for your server 9 8 10 9 … 11 var source = new Proj4js.Proj(‘EPSG:4236’); 12 var dest = new Proj4js.Proj(‘EPSG:42304’); 13 var p = new Proj4js.Point(-76.0,45.0); 14 Proj4js.transform(source, dest, p); 10 //somewhere in your JavaScript code where you need this 11 12 var source = new Proj4js.Proj(‘EPSG:4236’); //source coordinates will be in Longitude/Latitude 13 var dest = new Proj4js.Proj(‘EPSG:27563’); //destination coordinates in LCC, south of France 14 15 var p = new Proj4js.Point(-76.0,45.0); //any object will do as long as it has 'x' and 'y' properties 16 Proj4js.transform(source, dest, p); //do the transformation. x and y are modified in place 17 18 //p.x and p.y are now EPSG:27563 easting and northing in meters 15 19 … 16 20 17 21 }}} 18 22 19 p.x and p.y are now EPSG:42304 easting and northing in meters 23 == Proj4js.Proj constructor == 24 25 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]. 26 27 The argument to the constructor is a key in the Proj4js.defs initialization parameters object. 20 28 21 29 22 Every Proj object must be initialized with the parameters of the CRS to be used. 30 {{{ 31 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"; 32 }}} 33 23 34 24 35 == If you know the projections to be used in your application == 25 36 26 <script src="lib/defs/EPSG42304.js"></script > 37 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. 27 38 28 39 40 {{{ 41 <script src="lib/defs/EPSG27563.js"></script > 42 }}} 43 29 44 == Using dynamic lookup of initialization parameters == 45 46 set libPath 47 set proxy 48 spatialreference.org