<HTML><BODY><span style="font-family: Arial, Tahoma, Verdana, sans-serif; font-size: 13px; line-height: 18.2000007629395px;" data-mce-style="font-family: Arial, Tahoma, Verdana, sans-serif; font-size: 13px; line-height: 18.2000007629395px;">Ankur,</span><strong><strong><br><br></strong></strong><p>i am not familiar with ms4w, but it seems the principle is general.<br>First you need to configure WMS service, then to request it from client-side.</p><p>Example for a line data in Postgis, PHP Mapscript 6.4.1 and OpenLayers 3: </p><p>yourMapFile.map<br>----------<br>MAP<br>NAME "youMapName"<br>STATUS ON<br>UNITS METERS<br>OUTPUTFORMAT<br>NAME 'AGG'<br>DRIVER AGG/PNG<br>IMAGEMODE RGB<br>END #OUTPUTFORMAT<br>STATUS ON<br>WEB <br>METADATA<br>wms_title "youMap"<br>wms_abstract "youMap"<br>wms_onlineresource "http://localhost/youCode.php"<br>wms_srs "EPSG:3857" <br>wms_enable_request "*"<br>wms_encoding "utf-8"<br>END # end METADATA <br>END # end WEB <br>PROJECTION<br>"init=epsg:3857"<br>END # end PROJECTION <br>END # end MAP<br>-------------</p><p>youCode.php<br>----------- <br>$map = new Mapobj("yourMapFile.map"); <br>$request = new OwsrequestObj();<br>foreach ($_GET as $key => $value){ <br> $request->setparameter($key, $value); <br>}<br>$layer = ms_newLayerObj($map);<br>$layer->set('status', MS_ON);<br>$layer->set('name', 'yourLayerName');<br>$layer->setConnectionType(MS_POSTGIS);<br>$layer->set('connection', 'user=yourUser password=yourPass dbname=yourDB host=localhost');<br>$layer->set('type',MS_LAYER_LINE);<br>$layer->set("data","geom from (select id, geom from yourTable<br>where ST_Intersects(geom, !BOX!)) as subquery using unique id using srid=3857");<br>$class = ms_newClassObj($layer);<br>$class->set('name', 'yourClassName');<br>$style = ms_newStyleObj($class);<br>$style->color->setRGB(255,174,0);<br>$style->outlinecolor->setRGB(255,255,255);<br>$style->set('outlinewidth', 1); <br>$style->set('minwidth',5);<br>ms_ioinstallstdouttobuffer();<br>$map->owsDispatch($request); <br>$contenttype = ms_iostripstdoutbuffercontenttype();<br>header('Content-type:'.$contenttype);<br>ms_iogetStdoutBufferBytes();<br>ms_ioresethandlers();<br>-----------</p><p>request from client-side<br>-----------<br>var youWmsSource = new ol.source.ImageWMS({<br> url: 'http://localhost/youCode.php?', <br> params: {'LAYERS':'yourLayerName'},<br> serverType: 'mapserver'<br>});<br>see for more details: <br><a href="http://openlayers.org/en/v3.7.0/examples/wms-image.html?q=ImageWMS">http://openlayers.org/en/v3.7.0/examples/wms-image.html?q=ImageWMS</a><br><span class="hps">-----------<br><br>Hope</span> <span class="hps">this helps</span></p><style type="text/css"></style></BODY></HTML>