1

As per i know that there is an API called Openlayers.MapServer in openlayers 2, which is used to show MapServer file in browser in openlayers. How can i add an MapServer file in Openlayers 3, as i read somewhere that Openlayers 3 is currently under development for an API of MapServer, but please help me to add MapServer file in Openlayers 3.

5

There are two mode in MapServer in fact and it can be confusing for end users without knowledge about the project history.

  • The first one, the now mostly outdated mode cgi (the url contains mode=browse) way where you don't rely on standards OGC webservices. It was supported in OpenLayers 2 by default because of history (more Mapserver instances not using WMS at this time). In the OpenLayers version 3, you will have to custom ol.source.XYZ but there are not built-in component. This is your case according to your provided URL http://localhost:8081/cgi-bin/mapserv.exe?mode=browse&template=openlayers&layers=all&map=C:/ms4w/apps/osm/basemaps/osm-google.map

  • The second case where you use MapServer WMS abilities. You always use cgi Mapserver but the WMS way (no mode=browse). In this case, support is working for both OpenLayers 2 and 3. You just need to rely on the official samples mentioned in the comments.

IMO, instead of fighting with configuration on OpenLayers side, just configure your Mapserver mapfile to support WMS http://mapserver.org/ogc/wms_server.html and then use the OpenLayers 3 WMS default support.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.