2

I have a number of GeoTIFF files to be published in GeoServer and consume in OpenLayers.

I have published vector data and I was able to consume them in OpenLayers. However, I am not able to show a sample GeoTIFF layer on OpenLayers (I created by placing the tiff file in GeoServer directory and published from there).

I used TileWMS source with Tile layer and ImageWMS source with Image layer, either way nothing gets rendered in OpenLayers. How can I display the GeoTIFF layer in OpenLayers?

code :

var url = 'http://localhost:8080/geoserver/localhost/wms'

var multipleSrc = new ol.source.ImageWMS({
    projection: 'EPSG:32643',
    url: url,
    params: {
        //'FORMAT': 'image/png',
        'LAYERS': 'localhost:Tiff',//getCommaSeperatedLayersFromHT(),
        //'TRANSPARENT': 'TRUE',
        //'CQL_FILTER': 'INCLUDE'//getCommaSeperatedLayersFromCQL() //"INCLUDE;INCLUDE;INCLUDE;INCLUDE;INCLUDE;INCLUDE;INCLUDE;tehsil='Jatara'" // Working
    },
    serverType: 'geoserver',
    //transition: 0,
    //transparent: true,
    //opacity: 0.5,
});

 var layers = [
    EsriLayer,
    //OSMLayer,
    multipleLayer,
    vector
  ];

  var view = new ol.View({
      center: washingtonWebMercator,
      zoom: 5,
      maxZoom: 19.9
  })
  var map = new ol.Map({
    layers: layers,
    target: 'map',
    view: view
  });
  • 2
    TIF isn't supported by most browsers (internet explorer is an exception) so unless you want to be restricted to IE you would need to serve as a browser friendly format such as PNG – Mike Sep 25 '19 at 14:06
  • 1
    Thanks for the response ! We need to draw features on the TIFF, If PNG is supported then do I need to do any extra step to publish this as PNG ? Please suggest on how can I consume this in openlayers. Also, In chrome I am able to see the published layer through openlayers preview. – user684805 Sep 25 '19 at 14:17
  • 1
    A single geoTiff file size is around 80 MB – user684805 Sep 25 '19 at 15:21
  • 2
    @Mike, when you publish GeoTIFF with GeoServer through WMS it is usually not a tiff for the client anymore but some other image format like png or jpeg that the WMS server supports and WMS client requests. In this example OpenLayers request image data (natively a GeoTIFF) as jpeg demo.geo-solutions.it/geoserver/nurc/…. – user30184 Sep 25 '19 at 18:30
  • 2
    You cannot draw features directly on any raster layer, you must overlay it with a vector layer and draw on that. – Mike Sep 27 '19 at 18:57
2

I would go into the Layer Preview tab of the GeoServer admin console and select OpenLayers 3 (OL3) in the All Formats column. Then you can use the browser's devtools to see the network request and the parameters used to successfully display the image.

You can also do a View Page Source in your browser to take a look at the exact OL3 code used to display the image successfully by GeoServer in OL3.

Debugging layer issues

View Page Source results from the browser

| improve this answer | |

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.