Functions | Properties
Layer management
Map modules

Functions

int AxMap.AddLayer (object Object, bool Visible)
 Adds a layer to the map.
int AxMap.AddLayerFromDatabase (string connectionString, string layerNameOrQuery, bool visible)
 Adds a layer from spatial database accessed via GDAL/OGR drivers.
int AxMap.AddLayerFromFilename (string filename, tkFileOpenStrategy openStrategy, bool visible)
 Adds layer from the specified datasource.
void AxMap.Clear ()
 Removes all data from the map and sets its properties to the default state.
object AxMap.get_GetObject (int LayerHandle)
 Returns the layer object with the given handle. The object could be a Shapefile, Grid, or Image object.
Image AxMap.get_Image (int LayerHandle)
 Gets image object associated with the layer.
int AxMap.get_LayerHandle (int LayerPosition)
 Gets the handle of the layer at the given position in the map. Returns -1 if there is no layer at the specified position.
int AxMap.get_LayerPosition (int LayerHandle)
 Gets the position of the specified layer in the map.
bool AxMap.get_LayerVisibleAtCurrentScale (int layerHandle)
 Gets a value which indicates whether a layer is visible at current map scale.
OgrLayer AxMap.get_OgrLayer (int layerHandle)
 Gets instance of OGR layer object associated with the specified layer.
Shapefile AxMap.get_Shapefile (int LayerHandle)
 Gets shapefile object associated with the layer.
bool AxMap.MoveLayer (int InitialPosition, int TargetPosition)
 Moves a layer in the map from the initial position to a target position.
bool AxMap.MoveLayerBottom (int InitialPosition)
 Moves the specified layer below all other layers.
bool AxMap.MoveLayerDown (int InitialPosition)
 Moves the specified layer down one layer in the map.
bool AxMap.MoveLayerTop (int InitialPosition)
 Moves the specified layer to the top of all other layers.
bool AxMap.MoveLayerUp (int InitialPosition)
 Moves the specified layer up one layer in the map.
void AxMap.RemoveAllLayers ()
 Removes all layers from the map.
void AxMap.RemoveLayer (int LayerHandle)
 Removes the specified layer from the map.
void AxMap.RemoveLayerWithoutClosing (int LayerHandle)
 Removes layer from the map without its closing.
void AxMap.ReSourceLayer (int LayerHandle, string newSrcPath)
 Changes the data source for the specified layer without its closing.
void AxMap.set_Image (int LayerHandle, Image newValue)
 Replaces the image object associated with the layer.
void AxMap.set_Shapefile (int LayerHandle, Shapefile newValue)
 Replaces the shapefile object associated with the layer.

Properties

int AxMap.NumLayers [get]
 Gets the number of layers loaded in the map.

Detailed Description

Here is a list of properties and methods which allow to work with layers of the map. This module is a part of the documentation of AxMap class.

dot_inline_dotgraph_6.png

Graph description


Function Documentation

int AxMap.AddLayer ( object  Object,
bool  Visible 
)

Adds a layer to the map.

In case of OgrDatasource all layers will be added to the map. For grid datasources an instance of Image class created with Grid.OpenAsImage will be used for rendering.

Parameters:
ObjectThe object to add to the map. The following types are supported: Shapefile, Image, Grid, OgrLayer, OgrDatasource.
VisibleSets whether the layer is visible after being added to the map.
Returns:
Returns the integer handle for the layer added to the map.
Examples:
AddCategoryRange.cs, AddLayers.cs, CalculateArea.cs, CreateBuffer.cs, CreatePointShapefile.cs, CreatePolygonShapefile.cs, EditAttributes.cs, GenerateLabelsManually.cs, ImageLabels.cs, IntersectionLength.cs, LabelSelection.cs, LinePattern.cs, MarkPoints.cs, MinimalDistance.cs, PointIcons.cs, PolygonsWithHoles.cs, RemoveShape.cs, Segmentation.cs, SelectBox.cs, SelectByDistance.cs, SelectByQuery.cs, ShowAttributes.cs, SplitByAttribute.cs, ToolTip.cs, TrackCars.cs, Tracking.cs, and ZoomToValues.cs.
int AxMap.AddLayerFromDatabase ( string  connectionString,
string  layerNameOrQuery,
bool  visible 
)

Adds a layer from spatial database accessed via GDAL/OGR drivers.

This method will search if there is a layer with specified name in the datasource, and if so will open it. Otherwise it will run OgrDatasource.RunQuery method with provided layerNameOrQuery argument. Additional information on failure can be obtained through AxMap.FileManager property.

Parameters:
connectionStringConnection string. See details for particular formats here.
layerNameOrQueryName of the layer (i.e. database table) or SQL query.
visibleA value indicating whether a new layer will be visible.
Returns:
Handle of the newly added layer or -1 on failure.

The following example opens a temporary layer by querying PostGIS datatabase, adds the layer to the map and then accesses its data.

 private static string CONNECTION_STRING = "PG:host=localhost dbname=london user=postgres password=1234";
  
 string sqlOrLayerName = "SELECT * FROM Buildings WHERE gid < 50";    
 int handle = map.AddLayerFromDatabase(CONNECTION_STRING, sqlOrLayerName, true);
 if (handle == -1)
 {
     Debug.Print("Failed to open layer: " + map.FileManager.get_ErrorMsg(map.FileManager.LastErrorCode));
 
     // in case the reason of failure is still unclear, let's ask GDAL for details
     var gs = new GlobalSettings();
     Debug.Print("Last GDAL error: " + gs.GdalLastErrorMsg);
 }
 else
 {
     // now let's access the opened layer
     var l = map.get_OgrLayer(handle);
     if (l != null)
     {
         Debug.Print("Number of features: " + l.FeatureCount);
 
         // no access the data
         var sf = l.GetBuffer();
         Debug.Print("Number of shapes: " + sf.NumShapes);
     }
 }
New API 4.9.3:
Added in version 4.9.3
int AxMap.AddLayerFromFilename ( string  filename,
tkFileOpenStrategy  openStrategy,
bool  visible 
)

Adds layer from the specified datasource.

Additional information on failure can be obtained through AxMap.FileManager property.

Parameters:
filenameFilename of datasource
openStrategyOpen strategy (fosAutoDetect the default recommended value).
visibleA value indicating whether a new layer will be visible.
Returns:
Handle of the newly added layer or -1 on failure.
New API 4.9.1:
Added in version 4.9.1
Examples:
TrackCars.cs.
void AxMap.Clear ( )

Removes all data from the map and sets its properties to the default state.

New API 4.9.1:
Added in version 4.9.1
object AxMap.get_GetObject ( int  LayerHandle)

Returns the layer object with the given handle. The object could be a Shapefile, Grid, or Image object.

For OGR layers this method will return underlying shapefile from OgrLayer.GetBuffer(). Use AxMap.get_OgrLayer to access instance of OgrLayer itself.

Parameters:
LayerHandleThe handle of the layer to be retrieved.
Returns:
A Shapefile, Grid, or Image object.
Examples:
SortLayers.cs.
Image AxMap.get_Image ( int  LayerHandle)

Gets image object associated with the layer.

This method along with AxMap.get_Shapefile() can used to substitute AxMap.get_GetObject().

Parameters:
LayerHandleThe handle of the layer.
Returns:
The reference to the image or NULL reference in case of invalid handle or wrong layer type.
New API 4.8:
Added in version 4.8
int AxMap.get_LayerHandle ( int  LayerPosition)

Gets the handle of the layer at the given position in the map. Returns -1 if there is no layer at the specified position.

Parameters:
LayerPositionThe position of the layer for which the layer handle is required.
Returns:
The layer handle for the layer at the specified position.
Examples:
EditAttributes.cs, RemoveShape.cs, SelectBox.cs, SortLayers.cs, SplitByAttribute.cs, and ToolTip.cs.
int AxMap.get_LayerPosition ( int  LayerHandle)

Gets the position of the specified layer in the map.

Parameters:
LayerHandleThe layer handle of the layer for which the layer position is required.
Returns:
The layer position of the specified layer in the map.
Examples:
SortLayers.cs.
bool AxMap.get_LayerVisibleAtCurrentScale ( int  layerHandle)

Gets a value which indicates whether a layer is visible at current map scale.

Parameters:
layerHandleHandle of the layer.
Returns:
True in case the layer is visible.

The property checks whether or not the layer is hidden because of AxMap.LayerDynamicVisibility property. However it doesn't check that the layer has any objects within the current map extents.

New API 4.9.3:
Added in version 4.9.3
OgrLayer AxMap.get_OgrLayer ( int  layerHandle)

Gets instance of OGR layer object associated with the specified layer.

Parameters:
layerHandleThe handle of the layer.
Returns:
OGR layer or null in case of invalid layer index or wrong layer type.
New API 4.9.3:
Added in version 4.9.3
Shapefile AxMap.get_Shapefile ( int  LayerHandle)

Gets shapefile object associated with the layer.

This method along with AxMap.get_Image() can be used to substitute AxMap.get_GetObject().

Parameters:
LayerHandleThe handle of the layer.
Returns:
The reference to the shapefile or NULL reference in case of invalid handle or wrong layer type.
New API 4.8:
Added in version 4.8
Examples:
AddCategoryRange.cs, CalculateArea.cs, CreateBuffer.cs, EditAttributes.cs, GenerateLabelsManually.cs, LabelSelection.cs, MarkPoints.cs, PointIcons.cs, RemoveShape.cs, SelectBox.cs, SelectByQuery.cs, ShowAttributes.cs, SortLayers.cs, SplitByAttribute.cs, ToolTip.cs, TrackCars.cs, and ZoomToValues.cs.
bool AxMap.MoveLayer ( int  InitialPosition,
int  TargetPosition 
)

Moves a layer in the map from the initial position to a target position.

Parameters:
InitialPositionThe initial position of the layer to be moved.
TargetPositionThe final position of the layer being moved.
Returns:
bool AxMap.MoveLayerBottom ( int  InitialPosition)

Moves the specified layer below all other layers.

Parameters:
InitialPositionThe position of the layer to move to the bottom
Returns:
Boolean value representing success when true, and failure when false.
Examples:
SortLayers.cs.
bool AxMap.MoveLayerDown ( int  InitialPosition)

Moves the specified layer down one layer in the map.

Parameters:
InitialPositionThe position of the layer to be moved.
Returns:
Boolean value representing success when true, and failure when false.
bool AxMap.MoveLayerTop ( int  InitialPosition)

Moves the specified layer to the top of all other layers.

Parameters:
InitialPositionThe position of the layer to be moved.
Returns:
Boolean value representing success when true, failure when false.
bool AxMap.MoveLayerUp ( int  InitialPosition)

Moves the specified layer up one layer in the map.

Parameters:
InitialPositionThe initial position of the layer to be moved.
Returns:
Boolean value representing success when true, failure when false.

Removes all layers from the map.

Examples:
AddLayers.cs.
void AxMap.RemoveLayer ( int  LayerHandle)

Removes the specified layer from the map.

Parameters:
LayerHandleThe handle of the layer to be removed from the map.
void AxMap.RemoveLayerWithoutClosing ( int  LayerHandle)

Removes layer from the map without its closing.

Shapefile.Close or Image.Close won't be called while removing the layer.

Parameters:
LayerHandleThe handle of the layer.
void AxMap.ReSourceLayer ( int  LayerHandle,
string  newSrcPath 
)

Changes the data source for the specified layer without its closing.

The new data source must be of the same type, i.e. either Shapefile or Image.

Parameters:
LayerHandleThe handle of the layer.
newSrcPathThe the name of the new data source.
void AxMap.set_Image ( int  LayerHandle,
Image  newValue 
)

Replaces the image object associated with the layer.

The old image will not be closed.

Parameters:
LayerHandleThe handle of the layer.
newValueThe new image object.
New API 4.8:
Added in version 4.8
void AxMap.set_Shapefile ( int  LayerHandle,
Shapefile  newValue 
)

Replaces the shapefile object associated with the layer.

The old shapefile will not be closed.

Parameters:
LayerHandleThe handle of the layer.
newValueThe new shapefile object.
New API 4.8:
Added in version 4.8

Properties

int AxMap.NumLayers [get]

Gets the number of layers loaded in the map.

Examples:
AddLayers.cs, SortLayers.cs, and SplitByAttribute.cs.
 All Classes Files Functions Enumerations Properties Events