Tell me more ×
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've defined the following 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: googleProj,
    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 created map tiles by myself using mapnik. The map is visualized properly, but I have a shift problem when I try to add a vector layer as follows:

// feat = ...well formed GeoJson feature
var geojson_format = new OpenLayers.Format.GeoJSON({internalProjection: googleProj, externalProjection: salzburgProj});
var vector_layer = new OpenLayers.Layer.Vector(1);
vector_layer.addFeatures(geojson_format.parseFeature(feat));    
map.addLayer(vector_layer);

enter image description here

You can see the result in the image above: the vector layer (purple geometries) should be up-right shifted, in order to match the tiles below them. I do not understand why I obtain this behaviour: what is missing in my code?

share|improve this question
Why did you use OpenLayers.Layer.OSM, you should use OpenLayers.Layer.XYZ for custom tiles. Does your vector layer fit properly to default OSM layer? – drnextgis Sep 6 '12 at 16:30
I used OSM map because I have produced tiles with Mapnik as the OpenStreetMap project does, so I have for them the same OSM directory strucure on my machine ("tiles/input/${z}/${x}/${y}.png"). But my tiles are not in 900913 projection. Any hints to use XYZ map? – caneta Sep 7 '12 at 7:19

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.