0

Trying to add to my map an WMS layer with custom projection

When executing, the map does not show any layer.

Custom projection:

proj4.defs("EPSG:25830","+proj=utm +zone=30 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
register(proj4);
const customproj = getProjection('EPSG:25830');

WMS Layer:

var layer = 
  new TileLayer({
    source: new TileWMS({
      url: 'https://idena.navarra.es/ogc/wms',
      params: {'LAYERS': 'catastro'},
      projection: customproj
    })
  });

Map:

var map = new Map({
  target: 'map',
  layers: [layer],
  view: new View({
    projection: customproj,
    center: fromLonLat([-1.629950,42.63]),
    zoom: 9
  })
});

What's wrong here?

  • 1
    The map iis currently centered to default EPSG:3857 coordinates, it should be center: fromLonLat([-1.629950,42.63], customproj), – Mike Aug 30 at 9:53
  • You are right! Answer the question for marking it as solution @Mike – Iñigo Aug 30 at 9:56
  • Not sure it's correct to say custom projection for an EPSG defined CRS epsg-registry.org/export.htm?wkt=urn:ogc:def:crs:EPSG::25830 – nmtoken Aug 30 at 16:02
0

The map iis currently centered to default EPSG:3857 coordinates, it should be center: fromLonLat([-1.629950,42.63], customproj),

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.