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