ol-mapbox-style
ol-mapbox-style copied to clipboard
Projection in source of raster
Mapbox supports no projections, but openlayers does. According to the specification of mapbox style, there is no parameter for a projection. The only possibility for raster would be the schema "tms", which mapbox did not implement properly. Do you want to bring support for projection? And if so, maybe I can support you there.
I have no plans to add support for projections in ol-mapbox-style. If you need custom projections, use OpenLayers to set up your layers.
Hi @ahocevar, Thank you for this great plugin. I am trying to set up the layer using OpenLayers, but still I can't get the vector tiles to render in the custom projection. See the code below:
proj4.defs(
"EPSG:2163",
"+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"
);
ol.proj.proj4.register(proj4);
var projection = ol.proj.get("EPSG:2163");
var layer = new ol.layer.VectorTile({
declutter: true,
source: new ol.source.VectorTile({
attributions:
'© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
'© <a href="https://www.openstreetmap.org/copyright">' +
"OpenStreetMap contributors</a>",
format: new ol.format.MVT(),
url:
"https://maps.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?key=" +
openMapTilesKey
})
});
fetch(
"https://maps.tilehosting.com/styles/basic/style.json?key=" + openMapTilesKey
).then(function(response) {
response.json().then(function(style) {
olms.stylefunction(layer, style, "openmaptiles");
new ol.Map({
layers: [layer],
target: "map",
view: new ol.View({
projection: projection,
center: ol.proj.transform([8.23, 46.86], "EPSG:4326", "EPSG:2163"),
zoom: 1
})
});
});
});
Result:
Should look like this (Greenland should be smaller):
Do you have any hints?- What am I doing wrong?
This is not an ol-mapbox-style issue. I guess the tiles you are requesting from https://maps.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?key= are not in the projection you are referring to as EPSG:2163. And OpenLayers does not reproject vector tiles.