1

I'm trying to shown on the map the layer with the url , but I can not find the solution. However with the second layer it works. What I miss? And why?

I made this fiddle:

And yes, I have tried to change the projection, and even remove it.The layer would have to appear to the northwest of Africa, Canary Islands

EDIT: My bad sorry

link: http://idecan1.grafcan.es/ServicioWMS/MTL

fiddle: https://jsfiddle.net/nzx9fvz5/2/

var projec = new ol.proj.Projection({
  code: "EPSG:32628"
});
  var map = new ol.Map({
    layers: [
      new ol.layer.Tile({
        source: new ol.source.OSM()
      }),
      new ol.layer.Tile({
        source: new ol.source.TileWMS({
          url: "http://idecan1.grafcan.es/ServicioWMS/MTL",
          params: {'LAYERS': "LIDAR_MTL"},
          projection: projec
        })
      }),
      new ol.layer.Tile({
        source: new ol.source.TileWMS({
          url: "https://mesonet.agron.iastate.edu/cgi-bin/wms/us/mrms.cgi",
          params: {'LAYERS': "mrms"}
        })
      })
    ],
    target: 'map',
    view: new ol.View({
      center: [0, 0],
      zoom: 2
    })
  });
1

As is often the case with these questions you need to look at the server capabilities. This tells us it is a WMS and that it has one layer:

<Layer>
<Name>WMS_LIDAR_MTL</Name>
<Title>WMS LIDAR MTL</Title>
<Abstract>
Modelo de Terreno Lidar (MTL) generado con datos LIDAR. Propiedad de GRAFCAN. Esta información es libre y gratuita. Se prohibe la descarga masiva de información.
</Abstract>
<KeywordList>
<Keyword>WMS</Keyword>
<Keyword>MTL</Keyword>
<Keyword>LIDAR</Keyword>
<Keyword>MODELO</Keyword>
<Keyword>DIGITAL</Keyword>
<Keyword>MDS</Keyword>
<Keyword>MDT</Keyword>
<Keyword>CANARIAS</Keyword>
<Keyword>GRAFCAN</Keyword>
</KeywordList>
<CRS>EPSG:32628</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:32627</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-18.3099</westBoundLongitude>
<eastBoundLongitude>-13.1373</eastBoundLongitude>
<southBoundLatitude>26.1839</southBoundLatitude>
<northBoundLatitude>29.8305</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:32628" minx="180000" miny="2.9e+06" maxx="680000" maxy="3.3e+06"/>
<Layer queryable="1" opaque="0" cascaded="0">
<Name>LIDAR_MTL</Name>
<Title>Modelo Terreno LIDAR</Title>
<CRS>EPSG:32628</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-19.0427</westBoundLongitude>
<eastBoundLongitude>-12.52</eastBoundLongitude>
<southBoundLatitude>26.5097</southBoundLatitude>
<northBoundLatitude>30.0268</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:32628" minx="109794" miny="2.93809e+06" maxx="739222" maxy="3.32176e+06"/>
</Layer>
</Layer>

Looking closer we can see it supports exactly 3 projections (epsg:32628, epsg:32627 & epgs:4326), while in your code you never set the projection of the map so it defaults to epsg:3857 which the server doesn't know.

So something like this should work:

proj4.defs("EPSG:32628","+proj=utm +zone=28 +datum=WGS84 +units=m +no_defs");
var projec = new ol.proj.Projection({
  code: "EPSG:32628",
  extent: [166021.44, 0.00, 534994.66, 9329005.18],
  units: 'm'
});
ol.proj.addProjection(projec);
var map = new ol.Map({
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    }),
    new ol.layer.Tile({
      source: new ol.source.TileWMS({
        url: "http://idecan1.grafcan.es/ServicioWMS/MTL?service=wms",
        params: {
          'LAYERS': "LIDAR_MTL"
        },

      })
    })
  ],
  target: 'map',
  view: new ol.View({
    projection: 'EPSG:32628',

  })
});
0

I found the solution, the layer doesn't support png, only jpeg. So you need to especify the format:

... 
params: {'LAYERS': "WMS_LIDAR_MTL",
                   'FORMAT': 'image/jpeg'},
...

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.