Reputation: 715
I'm hoping the answer to this is quite simple and I just have something simple out of place.
In OpenLayers 1 I add a layer like this...
msSection = new OpenLayers.Layer.MapServer("Section",
MSBaseURL+"/MappingSection.map&",
{ layers: 'section', exceptions: "application/vnd.ogc.se_xml" },
{ isBaseLayer: false, opacity: 0.9 },
{ tileSize: new OpenLayers.Size(256, 256), buffer: 1 });
msSection.setVisibility(false);
the map file looks like this...
MAP
IMAGETYPE PNG24
CONFIG "PROJ_LIB" "C:/Program Files/MapServer/projlib/"
SIZE 256 256
FONTSET "D:/RCIS/Web/MapServerDlls/content/fontset.txt"
IMAGECOLOR 255 255 255
TRANSPARENT ON
PROJECTION
"init=epsg:4326"
END
LAYER
NAME "section"
TYPE POLYGON
STATUS ON
LABELCACHE ON
PROCESSING 'LABEL_NO_CLIP=1'
CONNECTIONTYPE PLUGIN
PLUGIN "msplugin_mssql2008.dll"
MAXGEOWIDTH .08
CONNECTION "server=someserver,someport;uid=someuser;pwd=somepassword;Initial Catalog=NATIONALDB;Integrated Security=False"
DATA "shape(geography),SECTION from NATIONALDB.sde.SECTION USING INDEX SECTION_SIDX USING UNIQUE SECTION_ID USING SRID=4269"
LABELITEM "SECTION"
CLASS
STYLE
OUTLINECOLOR 255 000 000
WIDTH 3
END
LABEL
COLOR 255 000 000
TYPE TRUETYPE
FONT Arial
SIZE 12
ANTIALIAS TRUE
POSITION CL
PARTIALS FALSE
#MINDISTANCE 300
#BUFFER 15
END
END
PROJECTION
"init=epsg:4326"
END
END
END
...and everything is happy and works... I try to add this in OpenLayers 3...
var Section = new ol.layer.Tile({
name: 'Section',
source: new ol.source.TileWMS({
url: 'http://localhost:8080/cgi-bin/mapserv.exe?map=D:/RCIS/Web/Mapfiles/MappingSection.map&',
params: { 'LAYERS': 'section' },
serverType: 'mapserver'
})
});
control.map.addLayer(Section);
...and it shows code 200 OK in chrome dev tools but does not work, when I put one of the tiles returned into the address bar I get this error..
<ServiceException>
msWMSDispatch(): WMS server error. WMS request not enabled. Check wms/ows_enable_request settings.
</ServiceException>
I'm completely confused by this, any help is greatly appreciated!!
Upvotes: 0
Views: 1434
Reputation: 2829
OpenLayers.Layer.MapServer
uses the MapServer CGI Controls to do its requests, not WMS. Since MapServer supports WMS, the CGI Controls are not used much anymore to draw map images with MapServer.
In OpenLayers 3, the format you're using is ol.source.TileWMS
, which produces WMS requests. If you inspect the request sent (see in your browser dev tool using the F12 key), you'll see that the requests sent to render the images are WMS requests, i.e. they do not use the MapServer CGI Controls.
What you need to do is change your mapfile to make it support WMS. See how it's done here: http://mapserver.org/ogc/wms_server.html. More specifically, look at the Setup a Mapfile For your WMS section.
Upvotes: 2