Last active
August 29, 2015 14:08
-
-
Save ThomasG77/7ffb661dd1e110b7ec8b to your computer and use it in GitHub Desktop.
Proj4js 2.x support with OpenLayers 2.x. Open the brower console to see the result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.3/proj4.js"></script> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js"></script> | |
<script type="text/javascript"> | |
//Snippet comes from http://osgeo-org.1560.x6.nabble.com/OL-2-13-1-latest-Proj4js-td5081636.html | |
window.Proj4js = { | |
Proj: function(code) { | |
return proj4(Proj4js.defs[code]); | |
}, | |
defs: proj4.defs, | |
transform: proj4 | |
}; | |
// Definition comes from http://epsg.io/31466/ | |
proj4.defs["EPSG:31466"] = "+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7 +units=m +no_defs"; | |
console.log(Proj4js.defs["EPSG:31466"]); | |
var proj_wgs84 = new OpenLayers.Projection("EPSG:4326"); | |
var proj_31466 = new OpenLayers.Projection("EPSG:31466"); | |
// Center for projection EPSG:31466 | |
var point = new OpenLayers.LonLat(2769212.70, 5678724.61); | |
var new_point= point.transform(proj_31466, proj_wgs84); | |
console.log(new_point.lat, new_point.lon); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment