I have a dataset in PostgreSQL that is in EPSG:27700, this is read by GoeServer and converted to .pbf files (using GeoWebCache). I have tile gridsets enabled for ESPG:27700,ESPG:4326,ESPG:900913. I am then rendering the tiles using OpenLayers/Mapbox GL.

When using ol.map I get tiles returned and all is working

var map = new ol.Map({
    target: 'map',
    view: new ol.View({
      Projection: 'EPSG:4326',
      center: schladmingWebMercator,
      zoom: 18
    layers: [new ol.layer.VectorTile({
      source: new ol.source.VectorTile({
        tilePixelRatio: 1, // oversampling when > 1
        tileGrid: ol.tilegrid.createXYZ({maxZoom: 19}),
        format: new ol.format.MVT(),
        defaultDataProjection: 'EPSG:4326',
        url: 'http://someserversomewhere:8080/geoserver/gwc/service/tms/1.0.0/' + layer +

However changing to mapbox.gl.map it no longer returns tiles as the map centre is outside my extents

var map = new mapboxgl.Map({
        container: 'map',
        minZoom: 15,
        maxZoom: 18,
        style: customStyleJson,
        center: centrepoin,
        zoom: 15,
        url: 'http://someserversomewhere:8080/geoserver/gwc/service/tms/1.0.0/' + layer +

I'm certain the projection is incorrect or not converting as required but I'm struggling to understand where in the connection a change needs to be made. Could somebody explain at what point a different projection can be requested (without any permanent transformation of data)? I notice the projection setting to 4326 in ol.map, is this possible in Mapbox GL?

1 Answer 1


Mapbox-gl seems to consider any tile grid to be a standard EPSG:3857 grid. Using other grids is sometimes possible but will usually involve some messy coding. I have managed to get other grids to work by making Mapbox-gl think they are standard EPSG:3857 - this requires supplying center coordinates adjusted for where they would be an EPSG:3857 grid instead of where they are on the real grid, and sometimes offsetting the z value in tile requests. This code https://jsfiddle.net/c209b3t1/ is based on the OpenLayers example https://openlayers.org/en/latest/examples/mapbox-layer.html which integrates a standard Mapbox-gl layer, but has been modified to work with the EPSG:4326 tiles from https://openlayers.org/en/latest/examples/vector-tiles-4326.html I have also successfully used the same technique with the EPSG:27700 grid from https://labs.os.uk/public/os-data-hub-examples/os-vector-tile-api/vts-27700-basic-map

Your Answer

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

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