[mapserver-users] MapScript C# Code Samples

Tamas Szekeres szekerest at gmail.com
Tue Sep 29 15:24:16 EDT 2009


2009/9/29 Daniel Walton <dgwalton at gmail.com>
>
> Sorry for the newbie question, but does anyone have any sample C# MapScript code they can share or point me to that would demonstrate :
>
> Adding a new map (based on a unique string name)


               mapObj  map = new mapObj(mapfilename);


> Adding a raster layer to the map (tiled tiff with overviews, WGS-84 + world file, no reprojection needed)

                layer = new layerObj(map);
                layer.connectiontype = MS_CONNECTION_TYPE.MS_RASTER;
                layer.type = MS_LAYER_TYPE.MS_LAYER_RASTER;
                layer.data = rasterfileName;
                layer.status = mapscript.MS_ON;


> Adding a shape layer to the map (ESRI shapefile)
>

                layer = new layerObj(map);
                layer.data= shapefileName;
                layer.connectiontype = MS_CONNECTION_TYPE.MS_SHAPEFILE;
                layer.status = mapscript.MS_ON;


You may also configure the map in your mapfile (mapfilename), and then
you only need to open the mapfile (see the first line of code above).

For further examples see:

http://trac.osgeo.org/mapserver/browser/trunk/mapserver/mapscript/csharp/examples/inline.cs
http://trac.osgeo.org/mapserver/browser/trunk/mapserver/mapscript/csharp/examples/drawmap.cs
http://www.paolocorti.net/2006/07/01/mapscript-c-tutorial-programming-mapserver-in-the-asp-net-framework/


Best regards,

Tamas


More information about the mapserver-users mailing list