I load wms from "geoportal" and it's good to time when I want show wms. Problems:

  • Hidden default map - I want that WMS overlays on OSM
  • Transform should be defined

It's look that: enter image description here

And some code:

var extent = [78912.472300001, 78524.1231000004, 875939.472300001, 948244.6231];

var projection = new ol.proj.Projection({
   code: 'EPSG:2180',
   extent: extent
ol.proj.addCoordinateTransforms('EPSG:4326', projection,
  function(coordinate) {
    return [
      WGStoCHy(coordinate[1], coordinate[0]),
      WGStoCHx(coordinate[1], coordinate[0])
  function(coordinate) {
    return [
      CHtoWGSlng(coordinate[0], coordinate[1]),
      CHtoWGSlat(coordinate[0], coordinate[1])

var WMS=new ol.layer.Image({
  extent: extent,
  source: new ol.source.ImageWMS({
    url: 'http://mapy.geoportal.gov.pl/wss/service/img/guest/TOPO/MapServer/WMSServer',
    crossOrigin: null,
    params: {
      'LAYERS': 'Raster',
      'FORMAT': 'image/png32',
    serverType: /** @type {ol.source.WMSServerType} */ ('mapserver')


 var _view=new ol.View({
    center: ol.proj.fromLonLat([0, 0], projection),
    zoom: 0,
    extent: extent,
    projection: projection,

I think you need to add:

proj4.defs("EPSG:2180","+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");

to your code so that OpenLayers "knows" how to transform to your projection.

In general you can look that string up on epsg.io

  • Thanks! Can you tell me why feautres are hidden when I switched layer on WMS? – Gabriel Domanowski Apr 24 '17 at 20:00
  • probably because by default WMS layers are baselayers – Ian Turton Apr 25 '17 at 7:40

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.