4

I am using Mapserver-wms-openlayers for publishing maps. But there are some issues came across related to duplicate labeling for same feature in adjacent tiles, unwanted breaks in line features along tile borders, labels cut along tile boarders. Not much documentations to clear this anywhere. Can I create single tile using mapserver wms? Just increasing the tile-size to container (map-div) size is enough?

My code is:

map = new OpenLayers.Map('map',
  {zoomDuration: 1,projection: 'EPSG:3857'}
);

var mymap_all = new OpenLayers.Layer.WMS("EOL",
"http://192.168.0.233/cgi-bin/mapserv?map=/var/www/ms‌​test/test_plant.map",
  {'layers':"map_outline",
   'transparent':true,
   'format':'image/p‌​ng'},
  {isBaseLayer: false,opacity: 100},
  {singleTile: true, ratio: 1}
);

var gmap = new OpenLayers.Layer.Google("Google Streets", // the default
  {numZoomLevels: 25,visibility: false},
  {isBaseLayer: true}
);

map.addLayers([mymap_all,gmap]);

See the cut off and duplicate labels along tile birders

See an individual tile.

mapsir
  • 428
  • 1
  • 6
  • 18

1 Answers1

4

This is a comparison between multiple tiles and single tile using WMS in OpenLayers:

var map = new OpenLayers.Map({
    div: "mapDiv",
    layers: [
        new OpenLayers.Layer.WMS(
            "Single Tile", 
            "http://vmap0.tiles.osgeo.org/wms/vmap0",
            {layers: "basic"}, 
            {singleTile: true, ratio: 1}
        ), 
        new OpenLayers.Layer.WMS(
            "Multiple Tiles", 
            "http://vmap0.tiles.osgeo.org/wms/vmap0",
            {layers: "basic"}
        )
    ],
    center: new OpenLayers.LonLat(6.5, 40.5),
    zoom: 4
});

map.addControl(new OpenLayers.Control.LayerSwitcher());

Here is the example:

http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/single-tile.html

Since you are also dealing with Google basemaps, you need to add mercator projections to your mapfile, these posts can guide you to do so:

with WFS:

http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze

Basically you need to adapt your projection settings (in OL and MS) to allow the correct display of your layers together.

Since MapServer understands WMS, you just need to pass your map file data as WMS like here. About your labels, using PARTIALS may solve your issue.

Gery
  • 2,135
  • 1
  • 15
  • 37
  • But, I am using Mapserver wms over google map. Code: – mapsir Jan 15 '14 at 08:50
  • @mapsir please take a look at my answer, I recently updated it. – Gery Jan 15 '14 at 09:18
  • Web portion already has got SRS info for both my wms and google. "wms_srs" "EPSG:4326 EPSG:3857" And tried both values for PARTIALS. Still I donot get single tile, but broken & duplicate labels. I will add an image to the question. – mapsir Jan 15 '14 at 09:39
  • @mapsir how do you know you have only a single tile? only for the labels? I'd be good if you can make a live demo to see the problem. – Gery Jan 15 '14 at 09:51
  • Gery, No. I am not getting single tile for the mapserver wms. It is still under localhost. I will add a single tile also to the question. – mapsir Jan 15 '14 at 10:05
  • @mapsir it's weird, it should work, could you post your mapfile also? – Gery Jan 15 '14 at 10:31
  • 3
    Added POSTLABELCACHE FALSE and PROCESSING "LABEL_NO_CLIP=ON" to the mapfile with other before mentioned parameters and label issue is solved. Now I can avoid single tile case. – mapsir Jan 15 '14 at 11:23
  • @mapsir glad to hear that your issue is solved =) – Gery Jan 15 '14 at 11:46
  • Now is there any significance for "wms_srs" "EPSG:4326 EPSG:3857" in WEB > METADATA? I think it has nothing to do with labels and can be removed. Anyway, Thanks Gery. – mapsir Jan 15 '14 at 11:54
  • You're welcome! well the WEB section in the map file is for projections, and since you're working with google you shouldn't delete it. – Gery Jan 15 '14 at 12:16
  • Is there a similar option (singleTile) for open layers 3 ? – Leandro Jan 18 '17 at 15:12