Code with issue on Codepen - Having successfully integrated the OpenRailwayMap API into Leaflet, I wanted to use OpenLayers instead and followed the API instructions, but am getting an error: " Cannot read property 'XYZ' of undefined". Can anyone see the issue here?


1 Answer 1


In your example you using OpenLayers3. In OL3 there is no OpenLayer.Layer.XYZ

But you can create your Layer with:

new ol.layer.Tile({
    source: new ol.source.XYZ({
        attributions: ['<a href="http://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, Style: <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA 2.0</a> <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> and OpenStreetMap'],
        url: 'http://{a-c}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png',
        tileSize: 512 //<- the ORM tiles are 512*512 Pixel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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