1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
---|
3 | <head> |
---|
4 | <title>Proj4js</title> |
---|
5 | |
---|
6 | <style type="text/css"> |
---|
7 | @import url(test/base.css); |
---|
8 | |
---|
9 | #descSource, #descDest { |
---|
10 | font-style: italic; |
---|
11 | color: #999; |
---|
12 | } |
---|
13 | |
---|
14 | #xySource, #xyDest { |
---|
15 | width: 100%; |
---|
16 | } |
---|
17 | |
---|
18 | </style> |
---|
19 | |
---|
20 | <script src="lib/proj4js.js"></script> |
---|
21 | |
---|
22 | <script src="lib/defs/EPSG27200.js"></script> |
---|
23 | <script src="lib/defs/EPSG4272.js"></script> |
---|
24 | <script src="lib/defs/EPSG54009.js"></script> |
---|
25 | <script src="lib/defs/EPSG42304.js"></script> |
---|
26 | <script src="lib/defs/EPSG25833.js"></script> |
---|
27 | <script src="lib/defs/EPSG27563.js"></script> |
---|
28 | <script src="lib/defs/EPSG4139.js"></script> |
---|
29 | <script src="lib/defs/EPSG4302.js"></script> |
---|
30 | <script src="lib/defs/EPSG31285.js"></script> |
---|
31 | <script src="lib/defs/EPSG900913.js"></script> |
---|
32 | |
---|
33 | <script type="text/javascript"> |
---|
34 | |
---|
35 | var projHash = {}; |
---|
36 | function initProj4js() { |
---|
37 | var crsSource = document.getElementById('crsSource'); |
---|
38 | var crsDest = document.getElementById('crsDest'); |
---|
39 | var optIndex = 0; |
---|
40 | for (var def in Proj4js.defs) { |
---|
41 | projHash[def] = new Proj4js.Proj(def); //create a Proj for each definition |
---|
42 | var label = def+" - "+ (projHash[def].title ? projHash[def].title : ''); |
---|
43 | var opt = new Option(label, def); |
---|
44 | crsSource.options[optIndex]= opt; |
---|
45 | var opt = new Option(label, def); |
---|
46 | crsDest.options[optIndex]= opt; |
---|
47 | ++optIndex; |
---|
48 | } // for |
---|
49 | updateCrs('Source'); |
---|
50 | updateCrs('Dest'); |
---|
51 | } |
---|
52 | |
---|
53 | function updateCrs(id) { |
---|
54 | var crs = document.getElementById('crs'+id); |
---|
55 | if (crs.value) { |
---|
56 | var proj = projHash[crs.value]; |
---|
57 | var str = 'projection: ' + proj.projName + ' - datum: ' + proj.datumName; |
---|
58 | var desc = document.getElementById('desc'+id); |
---|
59 | desc.innerHTML = str; |
---|
60 | var units = document.getElementById('units'+id); |
---|
61 | units.innerHTML = proj.units; |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | function transform() { |
---|
66 | var crsSource = document.getElementById('crsSource'); |
---|
67 | var projSource = null; |
---|
68 | if (crsSource.value) { |
---|
69 | projSource = projHash[crsSource.value]; |
---|
70 | } else { |
---|
71 | alert("Select a source coordinate system"); |
---|
72 | return; |
---|
73 | } |
---|
74 | var crsDest = document.getElementById('crsDest'); |
---|
75 | var projDest = null; |
---|
76 | if (crsDest.value) { |
---|
77 | projDest = projHash[crsDest.value]; |
---|
78 | } else { |
---|
79 | alert("Select a destination coordinate system"); |
---|
80 | return; |
---|
81 | } |
---|
82 | var pointInput = document.getElementById('xySource'); |
---|
83 | if (pointInput.value) { |
---|
84 | var pointSource = new Proj4js.Point(pointInput.value); |
---|
85 | var pointDest = Proj4js.transform(projSource, projDest, pointSource); |
---|
86 | document.getElementById('xyDest').value = pointDest.toShortString(); |
---|
87 | } else { |
---|
88 | alert("Enter source coordinates"); |
---|
89 | return; |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | </script> |
---|
94 | </head> |
---|
95 | |
---|
96 | <body onload="initProj4js()"> |
---|
97 | <div id="header"> |
---|
98 | <h1>Proj4js Home Page</h1> |
---|
99 | </div> |
---|
100 | <div id="navbar"> |
---|
101 | <a href="http://trac.osgeo.org/proj4js">Proj4js Wiki/Trac</a> | |
---|
102 | <a href="http://wiki.osgeo.org/wiki/MetaCRS">OSGeo MetaCRS</a> | |
---|
103 | <a href="http://spatialreference.org/">spatialreference.org</a> | |
---|
104 | <a href="http://communitymapbuilder.org/">MapBuilder</a> | |
---|
105 | <a href="http://openlayers.org/">OpenLayers</a> | |
---|
106 | </div> |
---|
107 | <h1>Welcome to Proj4js</h1> |
---|
108 | <p> |
---|
109 | This is a JavaScript library that provides methods for coordinate |
---|
110 | transformations between map projections and longitude/latitude, |
---|
111 | including datum transformations, in a web client. |
---|
112 | </p> |
---|
113 | |
---|
114 | <p> |
---|
115 | To use the Proj4js, you first create a source and destination Proj4js.Proj |
---|
116 | objects, passing in a projection code (e.g. EPSG:4326). |
---|
117 | You can then use the Proj4js.transform() method, passing in map XY as a point |
---|
118 | object and the source and destination projection objects, |
---|
119 | and it returns the point coordinate in the destination projection. |
---|
120 | </p> |
---|
121 | <form> |
---|
122 | <table> |
---|
123 | <tbody> |
---|
124 | <tr> |
---|
125 | <th colspan="3">source</th> |
---|
126 | <th></th> |
---|
127 | <th colspan="3">dest</th> |
---|
128 | </tr> |
---|
129 | <tr> |
---|
130 | <td>CRS:</td> |
---|
131 | <td colspan="2"> |
---|
132 | <select name="crsSource" id="crsSource" onchange="updateCrs('Source')"> |
---|
133 | <option value selected="selected">Select a CRS</option> |
---|
134 | </select> |
---|
135 | </td> |
---|
136 | <td></td> |
---|
137 | <td>CRS:</td> |
---|
138 | <td colspan="2"> |
---|
139 | <select name="crsDest" id="crsDest" onchange="updateCrs('Dest')"> |
---|
140 | <option value selected="selected">Select a CRS</option> |
---|
141 | </select> |
---|
142 | </td> |
---|
143 | </tr> |
---|
144 | <tr> |
---|
145 | <td></td> |
---|
146 | <td colspan="2" id="descSource">Projection - datum</td> |
---|
147 | <td></td> |
---|
148 | <td></td> |
---|
149 | <td colspan="2" id="descDest">Projection - datum</td> |
---|
150 | </tr> |
---|
151 | <tr> |
---|
152 | <td>x,y</td> |
---|
153 | <td><input name="xySource" id="xySource" type="text"/></td> |
---|
154 | <td id="unitsSource">units</td> |
---|
155 | <td><input type="button" value="--> transform -->" onclick="transform();"/></td> |
---|
156 | <td>x,y</td> |
---|
157 | <td><input name="xyDest" id="xyDest" type="text"></td> |
---|
158 | <td id="unitsDest">units</td> |
---|
159 | </tr> |
---|
160 | <tr> |
---|
161 | <td colspan="7" align="center"><input type="reset" value="reset"/></td> |
---|
162 | </tr> |
---|
163 | </tbody> |
---|
164 | </table> |
---|
165 | </form> |
---|
166 | <p> |
---|
167 | For more information on Proj4js and to report bugs, please visit the |
---|
168 | <a href="http://trac.osgeo.org/proj4js">Proj4js Trac and Wiki</a> at OSGeo. |
---|
169 | </p> |
---|
170 | |
---|
171 | </body> |
---|
172 | </html> |
---|