0

I have setup a map server in 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
0

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:

http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/osm/basemaps1/osm-google.map&service=WMS&request=GetCapabilities&

and similarly for a WFS like:

http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/osm/basemaps1/osm-google.map&service=WFS&request=GetCapabilities&

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:

http://ogc.bgs.ac.uk/cgi-bin/BGS_GSI_Geology/wms?language=eng&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=29.94358696243455853,77.35665599784030633,31.59091424368455847,79.93718124679318748&CRS=EPSG:4326&WIDTH=1496&HEIGHT=955&LAYERS=IND_GSI_2M_Faults&STYLES=&FORMAT=image/png&MAP_RESOLUTION=96&TRANSPARENT=FALSE&

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.