1

Maybe this could be a duplicated, but I can't find the right answer.

I'm using EPSG:25830 to default projection of my map. For this I've used proj4js :

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

var bounds25830 = [712397.500, 4374797.500, 742202.500, 4394802.500];
var proj25830 = ol.proj.get('EPSG:25830');
proj25830.setExtent(bounds25830);

Now I'm declaring some WMS Layers and adding to my map :

var ignBase = new ol.layer.Tile({
    name: 'IGN Base',
    visible: true,
    source: new ol.source.TileWMS({
        url: 'http://www.ign.es/wms-inspire/ign-base',
        crossOrigin: 'anonymous',
        params: {'FORMAT': 'image/png', 
                'VERSION': '1.1.1',
                transparent : false,
                tiled : true, 
                LAYERS: 'IGNBaseTodo',
                STYLES: '',
        }
    })
});

var layerVectorVacia = new ol.layer.Vector({
    title:'Vacía',
    name: 'base'
});

var groupCapasBase = new ol.layer.Group({
    name: 'Capas Base',
    layers: [layerVectorVacia, ignBase]
});

var mousePositionControl = new ol.control.MousePosition({
    coordinateFormat : ol.coordinate.createStringXY(2)
});
var map = new ol.Map({
    layers  : [
        groupCapasBase
    ],
    target  : 'map',
    controls: ol.control.defaults({ attribution : false }).extend([mousePositionControl]),
    view    : new ol.View({
        projection: proj25830,
        zoom      : 5,
        center    : [727300.000, 4384800.000]
    })
});

In the map, nothing is rendered, and if I look at the network panel, it appears that images have not been loaded. My first thought was that the request is badly formatted, but if I copy and paste some of the failing request in a browser, it returns the right image.

EDIT

I've noticed that if I use "FORMAT" : "image/jpeg" intead of "image/png" is rendering properly.

2
  • 2
    if I copy and paste some of the failing request in a browser, it returns the right image, can you clarify what you mean by this (some), what if you paste all of the request into a browser? Is it just image/png that fails, what about other supported image formats such as image/png8. As an aside too, I see you are requesting version 1.1.0, but the service doesn't appear to support that version (a 1.1.0 GetCapabilities request gives a 1.1.1 response)
    – nmtoken
    Sep 19, 2016 at 8:15
  • Sorry, just a typo the version, I'm using 1.1.1, What I meant by some, is in fact all the tiles of this services using image/png, if I use png8 as you said, it works. I'll edit with some images. If you want to write an answer I'll mark as accepted. =) Sep 19, 2016 at 11:26

1 Answer 1

2

I'm not sure why image/png doesn't work whilst image/jpeg does, possibly some driver issue on the server. A GetCapabilities request to the service shows that there are a number of image formats as below:

<GetMap>
  <Format>image/png</Format>
  <Format>application/pdf</Format>
  <Format>image/geotiff</Format>
  <Format>image/geotiff8</Format>
  <Format>image/gif</Format>
  <Format>image/gif;subtype=animated</Format>
  <Format>image/jpeg</Format>
  <Format>image/png8</Format>
  <Format>image/png; mode=8bit</Format>
  <Format>image/svg</Format>
  <Format>image/svg xml</Format>
  <Format>image/svg+xml</Format>
  <Format>image/tiff</Format>
  <Format>image/tiff8</Format>

If you want to use a portable network graphic image format, you could try the alternatively listed variants image/png8 or image/png; mode=8bit.

It would be worth contacting the service provider (contact details are in the GetCapabilities response), to make them aware of the situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.