1

I'm a bit stumped trying to read a EPSG:4326 WMS into a OpenLayers 3 project that's using the default 3857 (Web Mercator) projection.

I'm trying to pull a WMS layer that only supports EPSG:4326, but the projection option for ImageWMS appears to be "experimental" (http://openlayers.org/en/master/apidoc/ol.source.ImageWMS.html).

Lets say I have the below. The second layer is WGS84, but the first is 3857. How do I get it to work? Is this possible with OL3? I've not found any examples with it yet.

var layers = [
  //Default 3857 layer
  new ol.layer.Tile({
    source: new ol.source.MapQuest({layer: 'sat'})
  }),

  //This layer is in WGS84 (EPSG:4326)
  new ol.layer.Image({
    extent: [0, 40, 10, 50],
    source: new ol.source.ImageWMS({
      url: 'http://demo.boundlessgeo.com/geoserver/wms',
      params: {'LAYERS': 'topp:states'},
      serverType: 'geoserver'
    })
  })
];

var map = new ol.Map({
  layers: layers,
  target: 'map',
  view: new ol.View({
    center: [-10997148, 4569099],
    zoom: 4
  })
});
1
2

OpenLayers 3 cannot currently reproject images for you. We are planning to work on it in the future though. But currently you can only combine image / tile layers that are in the same projection. For vector layers reprojection is possible.

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.