Search code examples
openlayersleaflet

Custom tiles in local CRS without projection


Is it possible, to use openlayers 2 or 3 or leaflet with custom map tiles in a local CRS?

I have a map/plan of a very small area and I have a local CRS. Local CRS means: I have just x and y coordinates and don't care about projections. Each Coordinate can directly be mappend on the card by a simple calculation: PixelX = x * factorX + offsetX. Now I want to tell a web map application: Show the map tiles as base layer and take the upper left pixel of the first tile (0/0) as x=5126 and Y=24 and take the lower left pixel of the last tile at zoom level z as x=7256 and y=2344 (or something similar). How can I achieve this?

As far as I understand it now, I need any type of projection, but I don't need any projection in my project (in this small area, the world is flat). And I don't understand, how to tell OpenLayers (or maybe Leaflet, if OpenLayers doesn't support that): Here is my local CRS and the tiles have to be put into this CRS that way...


Solution

  • This seems to work in OpenLayers 2:

    var tiles = new OpenLayers.Layer.XYZ("Local tiles", "tiles/${z}/${x}/${y}.png", {
        isBaseLayer: true,
        maxExtent: [
            x1,
            y2,
            x2,
            y1
        ]
    });
    map.addLayer(tiles);
    

    x1/y1 are the coordinates of the upper left corner of the tile at zoom level 0 and x2/y2 the coordinates of the lower right corner.