Is it possible to show geodata by OpenLayers in custom projection?

I want to show my geodata in OpenLayers interface.

Source layer(s): shapefile(s), standard epsg:4326 lat/lon 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">
<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-4326 {
        float: left;
        clear: left;
    #shortdesc {
        margin-bottom: .5em;
        clear: left;
<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', 
    {map: 'C:/OSGeo4W/apache/htdocs/test/z-albers.map', layers: 'rus_general'}
        map.addControl(new OpenLayers.Control.LayerSwitcher() );
<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>

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', 
    {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"...

closed as too localized by underdark Nov 28 '12 at 21:38

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is this your full code? I don't see where you add a single base or overlay layer. – Vadim Sep 28 '12 at 17:53
  • No, it is only part of the code .. – Yakubailik Sep 29 '12 at 17:40
  • You shoul add your custom projection to epg file. Open your epsg file in a text editor and edit it. On Windows, the default location of the epsg file is c:\proj\nad. MS4W users will find the epsg file in \ms4w\proj\nad. – drnextgis Oct 1 '12 at 2:20
  • Have you solved this? – Plux Feb 24 '14 at 14:59
  • I had a similar problem earlier on however I was able to get around it by adding a custom projection using proj4js available here; wwww.proj4js.org load it into your project like so; <script src="js/proj4.js" type="text/javascript"></script> then define the custom projection like so (thats if you have the custom formula definition) in my own case; proj4.defs([ [ 'EPSG:26910', '+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs' ]]); Where "EPSG:26910" is the custom identifier for your projection – user28864 Oct 28 '14 at 10:56

Your code seems right. you have included proj4js because it is needed for projections other than 900913 and 4326 but, where is the OpenLayers.Layer.WMS pointing to your WMS server?

OpenLayers Cookbook can help you

  • Thanks for the link. I am very detail overlooked this book. Unfortunately, there does not discuss details on the custom projections... I really just gave a code snippet. Details are provided below. – Yakubailik Sep 29 '12 at 17:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.