Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have the following OpenLayers map:

Proj4js.defs["EPSG:31258"] = "+proj=tmerc +lat_0=0 +lon_0=13.33333333333333 +k=1 +x_0=450000 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs";
var googleProj = new OpenLayers.Projection("EPSG:900913");
var salzburgProj = new OpenLayers.Projection("EPSG:31258");
var bounds = new OpenLayers.Bounds(426249,294999,426251,295001);
var maxZoom = 19;
var minZoom = 15;
var res = [4.77731426696777,2.38865713348389,1.194328566741945,0.5971642833709725];

mapCOD = new OpenLayers.Map({
    div: "mapCODs",
    allOverlays: true,
    maxExtent: bounds,
    projection: salzburgProj,
    allowSelection: true,
    controls: [new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.Navigation()]
});

var layer = new OpenLayers.Layer.OSM(
        "layer1",
        "tiles/input/${z}/${x}/${y}.png",
        {zoomLevels: maxZoom, zoomOffset: minZoom, resolutions: res}
    );          
mapCOD.addLayer(layer);

I have produced tiles with mapnik using EPSG:31258, so I would like to change the default projection of the map from 900913 to 31258. The problem is that "projection" parameter is not taken into account and if I perform a console.log(mapCOD.getProjection()), I obtain "EPSG:900913".

Another proof that map projection remains 900913 is that I have to perform a coversion to get the correct map center:

var center = bounds.getCenterLonLat();
mapCOD.setCenter(center.transform(salzburgProj,googleProj), minZoom);

What am I missing?

share|improve this question

1 Answer 1

try this:

map.projection = new OpenLayers.Projection("EPSG:31258");
map.displayProjection = new OpenLayers.Projection("EPSG:4326");

or write like this:

mapCOD = new OpenLayers.Map('map', {           
    numZoomLevels: 20,
    projection: new OpenLayers.Projection("EPSG:31258"),
    displayProjection: new OpenLayers.Projection("EPSG: 4326")
});

i hope it helps you....

share|improve this answer
    
I've tried your solution: the map is still visible, but it's strange because the conversion operation remains mapCOD.setCenter(center.transform(salzburgProj,googleProj), minZoom); . I would like to get map center with a simple mapCOD.setCenter(center, minZoom);. And getProjection() continues to give me "EPSG:900913". Why have I to use two different projections? I would like to use the salzburg one, and that's it. –  caneta Sep 7 '12 at 7:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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