0

I have a OL5 map using a projection of EPSG:4326. I am adding a Vector Tile layer with a projection of ESPG:4326.

I am using Open Layers Mapbox Style (https://github.com/boundlessgeo/ol-mapbox-style) to apply a style to my Vector Tile I am seeing weird issues with how the styling is being rendered. I am a rookie with this stuff but I am assuming there is a disconnect with the Vector Tile Styling data vs the projection my map supports.

Any idea on why the below code does not seem to style the Vector Tile correctly?

Is this an issue with the plugin or an issue with the way the layer is configured?

Is it because "if the vector tile layer was built on a map with a projection of EPSG:3857 it can not be used/styled on a map with a different projection"?

// Create vector tile layer
var layer = new ol.layer.VectorTile({
    source: new ol.source.VectorTile({
    format: new ol.format.MVT({ featureClass: ol.render.Feature }),
    url: "https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf",
   projection: ol.proj.get("EPSG:4326")
   })
});
// Create map
var map = new ol.Map({
    target: 'map',
    view: new ol.View({
       projection: 'EPSG:4326',
       center: [0, 0],
       zoom: 2
    }),
    layers: [layer]
});

// Get style
$.get("https://www.arcgis.com/sharing/rest/content/items/291da5eab3a0412593b66d384379f89f/resources/styles/root.json")[![enter image description here][1]][1]   
.then(function(res) {
    olms.applyStyle(layer, res, "esri");
 });

vtIssues

  • Direct reprojection isn't supported,although someone has suggested it could be done indirectly by reprojecting a tileimage source taken from the canvas of a second hidden map! github.com/openlayers/openlayers/issues/6059 I had an issue wanting to reproject 3857 vector tiles onto a EPSG:27700 base and ended up reprojecting the base instead and then dynamically rotating and scaling to make it look like 27700 again. Declaring a 3857 source as 4326 might give some output, but out of place. – Mike Sep 23 '18 at 23:56
1

Turns out the issue was the resolutions were not being mapped to the proper zoom levels. The fix was as easy as passing in the layers resolutions as the fifth argument.

olms.applyStyle(layer, res, "esri", null, layer.getSource().getTileGrid().getResolutions());

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.