0
votes

I’m using OL3 with mapserver…the problem I’m having is that MapServer seems to be running fine, I have a .map file say for “States” like this…

MAP
IMAGETYPE      PNG24
CONFIG "PROJ_LIB" "C:/Program Files/MapServer/projlib/"
EXTENT         -180 -90 180 90
SIZE           256 256
FONTSET "E:/RCIS/Web/MapServerDlls/content/fontset.txt"
IMAGECOLOR     255 255 255
TRANSPARENT ON
PROJECTION 
 AUTO
END
            LAYER
                            GROUP "Base"
                            NAME "States"
                            TYPE POLYGON
                            STATUS ON
                            LABELCACHE ON 
                            PROCESSING 'LABEL_NO_CLIP=1' 
                            CONNECTIONTYPE PLUGIN
                            PLUGIN "msplugin_mssql2008.dll"
                            CONNECTION     "server=stbisqlr3.dvcorp.rcis.com,5208;uid=Mapping01D;pwd=9GreenSnap#4D;Initial Catalog=NATIONALDB;Integrated Security=False"
                            DATA "shape(geography),ST_NAME_MC from    NATIONALDB.sde.STATES USING INDEX STATES_SIDX USING UNIQUE STATES_ID USING   SRID=4269"
                            LABELITEM    "ST_NAME_MC"
                            CLASS
                                            STYLE                                     
                                             OUTLINECOLOR 000 153 000
                                            WIDTH 3
                                            END
                                            LABEL
                                                            COLOR 000 153 000
                                                            TYPE TRUETYPE
                                                            FONT Arial 
                                                            SIZE 12
                                                            ANTIALIAS FALSE
                                                            POSITION AUTO
                                                            PARTIALS FALSE
                                                            MINDISTANCE 2000
                                                            MINSCALEDENOM   20.00                                                               
                                            END
                            END                       
            PROJECTION 
                             AUTO
            END
            END       
END

And I build my map like so in OL3…

control.map = new ol.Map({
        target: 'map',
        renderer: 'canvas',
        layers: [],
        view: new ol.View({
            projection: 'EPSG:4326',
            center: [0, 0],
            zoom: 12
        })
    });

Create a vector layer that determines the extent, creates the view, and shows vector objects…which works!!

vectorObjs.promise.then(function () {
        //Create empty extent
        var extent = ol.extent.createEmpty();
        //Loop through vector layers to add them to map and determine extent


        var totalExtent = ol.extent;

        angular.forEach(webMapValues.vectorFieldLayer, function (Field, key) {                

            control.map.addLayer(Field);
            extent = Field.getSource().getExtent();
            totalExtent = ol.extent.extend(extent, totalExtent);
        })

        control.map.getView().fit(totalExtent, control.map.getSize());



        var view = new ol.View({
            center: control.map.getView().getCenter(),
            zoom: 8,
            minZoom: 1,
            maxZoom: 19

        });
        control.map.view = view;

Then I try to add the states layer to the map and everything seems like it’s working but I don’t see any state tiles?

var States = new ol.layer.Tile({
            name: 'States',
            extent: totalExtent,
            source: new ol.source.TileWMS({
               url: 'http://dvfmweb2:80/mapserver/mapserv.exe?map=E:/RCIS/Web/Mapfiles/MappingBase.map&',
                params: { 'LAYERS': 'States', 'BBOX': totalExtent, 'TILED': true }

            })
        });

        control.map.addLayer(States);

When I execute the call I see several line items in Chrome dev tools indicating state tiles i.e.

When I get tiles back in chrome this is the full information. 1. Request URL:

http://servername/mapserver/mapserv.exe? map=E:/RCIS/Web/Mapfiles/MappingStates.map&&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=States&BBOX=47.318115234375%2C-109.423828125%2C47.3291015625%2C-109.412841796875&TILED=true&WIDTH=256&HEIGHT=256&CRS=EPSG%3A4326&STYLES

  1. Request Method: GET

  2. Status Code: 200 OK

Additional Information!!!

When I paste one of the links in that get a "200 Ok" return code I can see an error that says...

<ServiceException code="InvalidSRS">
msWMSLoadGetMapParams(): WMS server error. Invalid CRS given : CRS must be  valid for all requested layers.
</ServiceException>

However I just see white?

Any help is greatly appreciated, I’ve been banging my head on this too long!!

-Bob

2
I haven't used MapServer so i am not sure if it helps but i think it can be picky about STYLE parameter. I recommend checking if default styling applies or a style name is required explicitly . Also, playing with style configuration may be a good idea. You can copy from a working layer configuration and see if it changes anything. - x82
within your map file I can see SRID=4269 while your ol3 map is projected on 4326 . I am not familiar with mapserver, mention it just in case - pavlos

2 Answers

0
votes

This turned out to be a problem with the Map File not being constructed correctly. The above is a map file that worked but the requirements must have changed...below is a map file that works. This can be used as a template for your system...Please pay attention to all the "your..." places in the map file you will need to fill in.

MAP
IMAGETYPE      PNG24
CONFIG "PROJ_LIB" "E:/your/path/to/projlib"
SIZE           256 256
FONTSET "E:/your/path/to/fontset.txt"
IMAGECOLOR     255 255 255
TRANSPARENT ON
PROJECTION 
 "init=epsg:4326"
END
WEB
  METADATA
    "wms_title" "states"
    "wms_enable_request"  "*"
  END
END
LAYER
    NAME "States"
    TYPE POLYGON
    STATUS ON
    LABELCACHE ON 
    PROCESSING 'LABEL_NO_CLIP=1' 
    CONNECTIONTYPE PLUGIN
    PLUGIN "msplugin_mssql2008.dll"
    CONNECTION      "server=YourServername.com,YourPort;uid=YouruserID;pwd=YourDBPassword;Initial    Catalog=YourDatabaseName;Integrated Security=False"
    DATA "shape(geography),YourStateColumnName from YourDatabaseName.STATES USING INDEX YourTableIndex USING UNIQUE YourStateIDColumn USING SRID=4269"
    LABELITEM    "YourStateNameColumn"
            PROCESSING "CLOSE_CONNECTION=DEFER"
    CLASS
        STYLE            
         OUTLINECOLOR 000 153 000
         WIDTH 3
        END
         LABEL
            COLOR 000 153 000
            TYPE TRUETYPE
            FONT Arial 
            SIZE 12
            ANTIALIAS FALSE
            POSITION AUTO
            PARTIALS FALSE

        END
    END     
    PROJECTION 
         "init=epsg:4326"
    END
END 
END

then save as States.map and point at it from your WMS

0
votes

You can only request a CRS that is listed as supported by the service/layer. So you had the error because your layer did not list EPSG:4326 as supported.

To list multiple CRS as supported you need to add a METADATA section to your layer (or the service, or both) expressing the CRS supported like:

METADATA
    "WMS_SRS" "CRS:84 EPSG:3857 EPSG:4269 EPSG:4326"
END