0

I am adding a WMS TileLayer from MapServer (format = image/png) to OpenLayers map. When I am zoomed in sufficiently, I see that the tiles are aligned perfectly. However, if I zoom out a little, the images turn black and blurred, eventually darkening out a portion of the map.

Below are small snips of the images. The blue square tile is a perfect tile (out of a cluster), visible when zoomed in, while the black mass below is the result when zoomed out.

Here is any of the code that is relevant:

//adding map
var map = new ol.Map({
        target: 'map',
        layers: [
            new ol.layer.Tile({
                source: new ol.source.OSM()
            })
        ],
        view: new ol.View({
            center: ol.proj.fromLonLat([LON, LAT]),
            extent: [minx, miny, maxX, maxy],
            minZoom: 4,
            zoom: 4
        })
    });

//defining params for adding TileWMS
var PARAMS = {
     FORMAT:"image/png",
     LAYERS:"name_of_layer",
     MAP:"mapfile.map",
     VERSION:"1.3.0",
     SERVICE: "WMS",
     REQUEST: "GetMap"
}

//adding TileWMS layer
var layer = new ol.layer.Tile({
            source: new ol.source.TileWMS({
            url: http://localhost/MapServer/mapserv.exe,
            params: PARAMS,
            serverType: "mapserver",
            ratio: 1,
            projection: projection
     })
});

I also checked the urls returned by OpenLayers at different zoom levels (when OL makes a WMS request) and found that only some of the urls in which I was zoomed in more gave an image while other urls just gave a black screen on the browser.

Can someone help?

I have added the red scribbling in the second manually as I was not sure if I can reveal the labels.

Zoomed inZoomed Out

Here is the MapFile which is being generated

MAP
  CONFIG "PROJ_LIB" "C:\\MapServer\\bin\\proj\\SHARE"
  CONFIG "GDAL_DATA" "C:\\MapServer\\bin\\gdal-data"
  EXTENT -1 -1 1 1
  IMAGETYPE "png"
  NAME "ZOO-Project_WXS_Server"
  SIZE 2048 2048
  STATUS ON
  SYMBOLSET "c:/inetpub/wwwroot/data//symbols.sym"
  TRANSPARENT TRUE
  UNITS METERS

  OUTPUTFORMAT
    NAME "png"
    MIMETYPE "image/png"
    DRIVER "AGG/PNG"
    EXTENSION "png"
    IMAGEMODE RGB
    TRANSPARENT FALSE
  END # OUTPUTFORMAT

  OUTPUTFORMAT
    NAME "kml"
    MIMETYPE "application/vnd.google-earth.kml+xml"
    DRIVER "KML"
    EXTENSION "kml"
    IMAGEMODE RGB
    TRANSPARENT FALSE
    FORMATOPTION "ATTACHMENT=mapserver.kml"
  END # OUTPUTFORMAT

  OUTPUTFORMAT
    NAME "tiff"
    MIMETYPE "image/tiff"
    DRIVER "GDAL/GTiff"
    EXTENSION "tif"
    IMAGEMODE BYTE
    TRANSPARENT FALSE
  END # OUTPUTFORMAT

  OUTPUTFORMAT
    NAME "grd"
    DRIVER "GDAL/AAIGRID"
    EXTENSION "asc"
    IMAGEMODE INT16
    TRANSPARENT FALSE
  END # OUTPUTFORMAT

  OUTPUTFORMAT
    NAME "cairopng"
    MIMETYPE "image/png; mode=24bit"
    DRIVER "CAIRO/PNG"
    EXTENSION "png"
    IMAGEMODE RGBA
    TRANSPARENT TRUE
  END # OUTPUTFORMAT

  PROJECTION
    "init=epsg:4326"
    "+epsgaxis=ne"
  END # PROJECTION
  LEGEND
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE 10
      OFFSET 0 0
      SHADOWSIZE 1 1
    END # LABEL
    STATUS OFF
  END # LEGEND

  QUERYMAP
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END # QUERYMAP

  SCALEBAR
    INTERVALS 4
    LABEL
      SIZE 10
      OFFSET 0 0
      SHADOWSIZE 1 1
    END # LABEL
    SIZE 200 3
    STATUS OFF
    UNITS MILES
  END # SCALEBAR
  WEB
    IMAGEPATH "c:/inetpub/wwwroot/tmp/"
    IMAGEURL "http://localhost/tmp/"
    METADATA
      ... (deliberately hidden)
    END # METADATA
  END # WEB

  LAYER
    CONNECTION "c:/inetpub/wwwroot/data//ZOO_DATA_Region_Map_930fa917-e258-4ae2-9f81-cadf69a22695.data"
    CONNECTIONTYPE OGR
    DATA "data"
    METADATA
      "gml_featureid"   "gml_id"
      "ows_name"    "Name"
      "ows_srs" "EPSG:4326 EPSG:900913"
      "ows_title"   "Title"
      "gml_include_items"   "all"
    END # METADATA
    NAME "Region_Map"
    STATUS ON
    TYPE POLYGON
    UNITS METERS
    CLASS
      STYLE
        COLOR 125 125 255
        OUTLINECOLOR 80 80 80
        WIDTH 3
      END # STYLE
    END # CLASS
  END # LAYER

END # MAP
  • Show us your mapfile. The issue don't seem in OpenLayers but your back-end – ThomasG77 Jun 30 '18 at 11:24
  • @ThomasG77 I've added the MapFile contents. – M J Learner Jun 30 '18 at 11:43

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.