Is it possible to show geodata by OpenLayers in custom projection?
I want to show my geodata in OpenLayers interface.
Source layer(s): shape-file(s), standard epsg:4326 lon/lat projection; processed by Mapserver (WMS Layers).
Result map: Albers Conic Equal Area projection, with specific central meridian (It has no EPSG code).
Definition in PROJ.4 format:
+proj=aea +lat_1=52 +lat_2=64 +lat_0=0 +lon_0=93 +x_0=16500000 +y_0=0 +ellps=krass +units=m +towgs84=28,-130,-95,0,0,0,0 +no_defs
As to Mapserver Layers – they are all well, I can show geodata through standard Mapserver CGI template-based interface, in this custom Albers projection…
For OpenLayers I tried to define Proj4js.defs –
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="ol/style.css" type="text/css" />
<style type="text/css">
#map {
width: 800px;
height: 500px;
border: 1px solid black;
}
#mouse-position-meters,
#mouse-position-4326 {
float: left;
clear: left;
}
#shortdesc {
margin-bottom: .5em;
clear: left;
}
</style>
<script src="lib/OpenLayers.js"></script>
<script src="lib/proj4js-compressed.js"></script>
<script type="text/javascript">
Proj4js.defs["USER:00001"] = "+proj=aea +lat_1=52 +lat_2=64 +lat_0=0 +lon_0=93 +x_0=16500000 +y_0=0 +ellps=krass +units=m +towgs84=28,-130,-95,0,0,0,0 +no_defs";
function init(){
map = new OpenLayers.Map('map', {
projection: 'USER:00001',
maxResolution: 'auto',
units: 'm',
controls: [
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.MousePosition({
div: $('mouse-position-meters'),
prefix: 'Coords: (',
suffix: ') m (ALBERS).'
}),
new OpenLayers.Control.MousePosition({
div: $('mouse-position-4326'),
displayProjection: new OpenLayers.Projection('EPSG:4326'),
prefix: 'Coords: (',
suffix: ') dd (EPSG:4326).'
})
],
maxExtent: new OpenLayers.Bounds(12460000, 4870000, 20540000, 9500000)
});
var rus_general = new OpenLayers.Layer.MapServer('Russian Regions',
'http://localhost/cgi-bin/mapserv.exe',
{map: 'C:/OSGeo4W/apache/htdocs/test/z-albers.map', layers: 'rus_general'}
);
map.addLayer(rus_general);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.LayerSwitcher() );
}
</script>
</head>
<body onload="init()">
<h1 id="title">OpenLayers Test</h1>
<div id="map" class="smallmap"></div>
<div id="mouse-position-meters"></div>
<div id="mouse-position-4326"></div>
</body>
</html>
It seems that the presented coordinate transformation works correctly (displaying the appropriate numbers when I move the mouse), but the map does not appear…
How can I do this?
====================
Discussion of the problem & Answer to the question --
It looks like I found the answer myself...
(The above source code has been corrected, and already has a working version)
I changed WMS-layer upon layer of MapServer type
Original (non-working) version was:
...
var rus_general = new OpenLayers.Layer.WMS( 'Russian Regions',
'http://localhost/cgi-bin/mapserv.exe?map=C:/OSGeo4W/apache/htdocs/test/z-albers.map',
{layers: 'rus_general'}
);
...
In this case, the bottleneck - WMS-service: I do not know how to specify a custom (non-EPSG) projection in this case ...
This is not a problem for the Mapserver layer type. Mapserver generates a map projection with PROJECTION section in the MAP-file. There are no restrictions such as "EPSG Only"...
Thank you all.