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
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.addProjection(projection);
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',
//'TRANSPARENT':true,
},
serverType: /** @type {ol.source.WMSServerType} */ ('mapserver')
})
});
Views:
var _view=new ol.View({
center: ol.proj.fromLonLat([0, 0], projection),
zoom: 0,
extent: extent,
projection: projection,
});