Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projection in source of raster #191

Open
GD-Aichi opened this issue Mar 26, 2019 · 3 comments
Open

Projection in source of raster #191

GD-Aichi opened this issue Mar 26, 2019 · 3 comments

Comments

@GD-Aichi
Copy link
Contributor

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.

@ahocevar
Copy link
Member

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.

@manuelroth
Copy link

manuelroth commented May 2, 2019

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:
Screenshot 2019-05-02 at 12 08 39
Should look like this (Greenland should be smaller):
Screenshot 2019-05-02 at 12 09 03

Do you have any hints?- What am I doing wrong?

@ahocevar
Copy link
Member

ahocevar commented May 2, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants