OpenLayers – How to Include Proj4js in OpenLayers 2

coordinate systemopenlayers-2proj

In my Openlayers app, since the base map projection is not epsg900913 or 4326, I need to include proj4js in order to use geolocation feature. but I got such an error notice:

 GET http://svn.osgeo.org/metacrs/proj4js/trunk/lib/projCode/null.js 404 (Not Found)

I am wondering how come this null.js is needed here. the funny thing is I can't find this file from proj4js lib files..

anybody can help me out?

Code:

<!DOCTYPE html> 
<html> 
    <head> 
<link rel="stylesheet" href="theme/default/style.css" type="text/css"> 
<link rel="stylesheet" href="style.css" type="text/css"> 
<script type="text/javascript" src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js.js"></script>
<script src="http://openlayers.org/dev/OpenLayers.js"></script> 

    </head> 
    <body> 
    <div id="map" class="smallmap"></div> 
<script  type="text/javascript">
    var map = new OpenLayers.Map({
    div: "map",
    projection: new OpenLayers.Projection("EPSG:26912"),
    layers: [
        new OpenLayers.Layer("",{isBaseLayer: true}),
        new OpenLayers.Layer.Vector("KML", {
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: "test.kml",
                format: new OpenLayers.Format.KML({
                    extractStyles: true, 
                    extractAttributes: true,
                    maxDepth: 2
                })
            })
        })
    ]
});

map.zoomToMaxExtent();
</script>
    </body> 
</html> 

Best Answer

After looking at your code it seems the error is in the definition of EPSG26912 where a colon is missing. Try the changes on local copy and then report them to the developers. You should never link to code from SVN trunk, anyway because of both performance and stability issues. Instead use a stable version of proj4js or a local checkout.