2

Using OpenLayers 7.3, my goal is to display a Vector Tile Layer (VTL) that has a coordinate system of EPSG:7856, with other layers (Tile and Vector layers) that have coordinate systems in EPSG:3857 (Web Mercator).

I've got the projection from EPSG's website and registered it in OpenLayers:

import proj4 from 'proj4';
import {register} from 'ol/proj/proj4.js';
import {get as getProjection} from 'ol/proj.js';

proj4.defs("EPSG:7856","+proj=utm +zone=56 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs");
register(proj4);
let proj7856 = getProjection(projCode);

But I don't understand where I should be setting this. Thinking out loud, if I want to project all layers in the Map to one coord system, can I not use OpenLayers default projection of EPSG:3857, in which case would I expect OpenLayers to discover the VTL is in EPSG:7856 and automatically project it to EPSG:3857, along with the other layers?

Or do I set the projection on the Map View as well as all layers to EPSG:7856?

I haven't had success with either, hence my post. Trying either option, the VTL is rendered at a much larger scale than the other layers.

3
  • Please edit your question and add code of how you create/define your VTL layer.
    – TomazicM
    Apr 7, 2023 at 7:38
  • 3
    Vector tiles can only be used in their native projection, but you can reproject other layers on the map to that projection. Also vector tiles in projections other than EPSG:3857 will use a custom tile grid which must be defined. For example EPSG:27700 vector tiles in a custom grid with the background OSM reprojected to EPSG:27700 codesandbox.io/s/simple-forked-rgxtkc?file=/main.js
    – Mike
    Apr 7, 2023 at 10:47
  • 1
    @Mike - please make that comment an answer so we can up vote it
    – Ian Turton
    Apr 7, 2023 at 16:06

1 Answer 1

3

Vector tiles can only be used in their native projection, but you can reproject other layers on the map to that projection. Also vector tiles in projections other than EPSG:3857 will use a custom tile grid which must be defined. For example EPSG:27700 vector tiles in a custom grid with the background OSM reprojected to EPSG:27700 https://codesandbox.io/s/simple-forked-rgxtkc?file=/main.js

2
  • Thankyou @Mike, that's set me on the right track. I'm still having trouble lining up the layers but this is because the origin point is different to the extent. In your example, the VTL origin is the same point as the extent xmin and ymax (see api.os.uk/maps/vector/v1/…). Would you know how to configure openlayers if the origin point is different to the extent?
    – Steve
    Apr 10, 2023 at 23:44
  • 2
    The normal extent of EPSG:27700 is [0, 0, 700000, 1300000] but overview maps often use a larger extent to include Ireland, so the example has increased the extent to match the tile grid. The tile grid for the example is defined by the service json for the style as in labs.os.uk/public/os-data-hub-examples/os-vector-tile-api/… but for simplicity I hardcoded the values and limited the zoom levels to those accessible with a free API key.
    – Mike
    Apr 11, 2023 at 8:53

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.