0

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

I have published vector data and able to consume them in openlayers, However I am not able to show a sample GeoTIFF layer on OpenLayers (I created by placing the till 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
  });
  • 1
    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 at 14:06
  • 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 at 14:17
  • A single geoTiff file size is around 80 MB – user684805 Sep 25 at 15:21
  • 1
    @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 at 18:30
  • 1
    You cannot draw features directly on any raster layer, you must overlay it with a vector layer and draw on that. – Mike Sep 27 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.