[GIS] How to save vector layer as a file in OpenLayers

feature-layerlineopenlayers-2pointpolygon

I'm using MapServer + OpenLayers for GIS API and I'm new to GIS. I'm done with drawing line, point and polygon features in OpenLayers, but not being able to save it in some shapefile afterwards. I got to display the particular shapefile in map on click event. I have got no idea about how to do it.

Click here to see my code

Best Answer

OpenLayers runs in the browser, and does not provide a method for generating shapefiles.

What I would suggest is generating GeoJSON of your drawn featurres and POSTing that to the server, where you can use your language of choice to generate a shapefile from the GeoJSON.