1

I am a newbie to Openlayers and currently dealing with a problem in setting up a custom tile-map. I have a base tile at zoom = 0 as png which has an extent of 56 by 56 kilometres and a resolution of 218.75 meters. Currently the tile-archive goes down to zoom-level 4. I used the projection in EPSG:25833 in proj4 and displayed the tiles via ol.source.xyz. I defined extent and resolution. However the map is not displayed at the correct coordinates. On loading it jumps to a higher zoom-level than entered and displays a small part of a tile. When zooming out the defined extent is just a small rectangle in the center of the map and coordinates go up to exorbitant numers around this extent.

I searched in stackexchange an in the OL-Apidoc, but could not find my error.

Here is my current code:

proj4.defs('EPSG:25833', '+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84  +units=m +no_defs');
var projection25833 = ol.proj.get("EPSG:25833");

var tileLayer = new ol.layer.Tile({
    source: new ol.source.XYZ({
        projection: projection25833,
        url: "{z}/{x}/{-y}.png",
        extent: [364900,5791100,420900,5847100],
        tileSize: [256, 256],
        minZoom: 0,
        maxZoom: 4
    })
});

var myView = new ol.View({
    projection: projection25833,
    extent: [364900,5791100,420900,5847100],
    center: [392900, 5819100],
    resolution: 218.75,
    zoom: 0,
    minZoom: 0,
    maxZoom: 4
});

var map = new ol.Map({
    target: "mapDIV",
    layers: [tileLayer],
    view: myView
});
1

I obviously found an own solution for this problem. Because OL by default uses its own zoom-levels, "0" means a global view. I had to define a custom projection with the given extent to fix this problem:

var projection25833bln = new ol.proj.Projection({
    code: "EPSG:25833bln",
    global: false,
    extent: [364900,5791100,420900,5847100]
});

The question remains whether I still need proj4 for eventually transforming WGS84-coordinates into UTM or vice versa.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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