I have setup MapServer (MS4W) on my local Windows machine, and can access the map with this link http://localhost/cgi-bin/mapserv.exe?template=openlayers&layers=all&map=C:/ms4w/apps/osm/basemaps1/osm-google.map

My requirement is I want directly jump to a lat long with zoom value and show marker on lat long.

I looked into OpenLayers and with a overview I think it is good for my requirement. How can I setup my map=C:/ms4w/apps/osm/basemaps1/osm-google.map with OpenLayers?

  • As I understand it the openlayers template is really just a quick way of testing/demoing your mapserver service, if you want to be able to go to a particular location, you'll need to drop that template and use a WMS or WFS, though even then you can use application/openlayers& as output format for the WMS.
    – nmtoken
    Nov 10 '18 at 10:52

Most probably you should configure MapServer as a WMS. To zoom to a location of interest you'd need set an appropriate bounding box and map image size specified in pixels.

You can check whether you already have a WMS configured (or part configured) by using the following request:


and similarly for a WFS like:


Let's consider a MapServer based service for India as below. There is a WMS configured as well but the output here is using the openlayers template:

MapServer service output using openlayers template

Let's say I want to have a link that goes directly to the small cluster of faults in the North.

I need to use a WMS GetMap operation to specify the area of interest, to zoom to that location, something like:


Which gives us an image/png output like below:

MapServer WMS image/png output

Or if you wanted an OpenLayers output you could change the FORMAT=image/png& parameter to FORMAT=application/openlayers& to give you:

MapServer WMS application/openlayers output

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.