This example demonstrates how to add all the shapefiles and images with .tif and .png extensions from the specified folder to the map. Here is a screenshot with the results of the code execution.
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using AxMapWinGIS;
using MapWinGIS;
namespace Examples
{
public partial class MapExamples
{
public bool AddLayers(
AxMap axMap1,
string dataPath)
{
try
{
string[] files = Directory.GetFiles(dataPath);
foreach (string file in files)
{
int layerHandle = -1;
if (file.ToLower().EndsWith(".shp"))
{
{
layerHandle = axMap1.
AddLayer(sf,
true);
}
else
}
else if (file.ToLower().EndsWith(".tif") ||
file.ToLower().EndsWith(".png"))
{
{
layerHandle = axMap1.
AddLayer(img,
true);
}
else
}
if (layerHandle != -1)
}
}
finally
{
Debug.Print(
"Layers added to the map: " + axMap1.
NumLayers);
}
}
}
}
ImageType
The type of images supported by MapWinGIS.
Definition: Enumerations.cs:92
tkLockMode
The lock mode of the map, either locked or not.
Definition: Enumerations.cs:940
Map component for visualization of vector, raster or grid data.
Definition: AxMap.cs:56
Represents an raster image of particular format which may be added to the map.
Definition: Image.cs:66
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
int LastErrorCode
Gets the code of last error which took place inside this object.
Definition: Shapefile.cs:249
int LastErrorCode
Retrieves the last error generated in the object.
Definition: Image.cs:466
bool Open(string ImageFileName, ImageType fileType, bool InRam, ICallback cBack)
Opens an image from file.
Definition: Image.cs:357
void LockWindow(tkLockMode lockMode)
Locks the window so that any changes will not be displayed until it is unlocked.
Definition: AxMap.cs:524
int NumLayers
Gets the number of layers loaded in the map.
Definition: AxMap.cs:1422
int AddLayer(object Object, bool visible)
Adds a layer to the map.
Definition: AxMap.cs:1342
void RemoveAllLayers()
Removes all layers from the map.
Definition: AxMap.cs:1429
void set_LayerName(int layerHandle, string newValue)
Sets the name of the specified layer.
Definition: AxMap.cs:1168
bool Open(string shapefileName, ICallback cBack)
Opens shapefile from the disk.
Definition: Shapefile.cs:1430