This example demonstrates how to how to add markers for the points of interest. The marker represented by image loaded from the file will be added on the mouse down event. The markers will be stored in the temporary in-memory shapefile. Here is a screenshot with the results of the code execution.

using System.IO;
using System.Windows.Forms;
using AxMapWinGIS;
using MapWinGIS;
namespace Examples
public partial class MapExamples
// the handle of the layer with markers
private int m_layerHandle = -1;
// <summary>
// Loads the layers and registers event handlers
// </summary>
public void MarkPoints(AxMap axMap1, string dataPath)
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
string filename = dataPath + "buildings.shp";
if (!File.Exists(filename))
MessageBox.Show("Couldn't file the file: " + filename);
var sf = new Shapefile();
sf.Open(filename, null);
m_layerHandle = axMap1.AddLayer(sf, true);
sf = axMap1.get_Shapefile(m_layerHandle); // in case a copy of shapefile was created by GlobalSettings.ReprojectLayersOnAdding
sf = new Shapefile();
if (!sf.CreateNewWithShapeID("", ShpfileType.SHP_POINT))
MessageBox.Show("Failed to create shapefile: " + sf.ErrorMsg[sf.LastErrorCode]);
m_layerHandle = axMap1.AddLayer(sf, true);
ShapeDrawingOptions options = sf.DefaultDrawingOptions;
options.PointType = tkPointSymbolType.ptSymbolPicture;
options.Picture = this.OpenMarker(dataPath);
sf.CollisionMode = tkCollisionMode.AllowCollisions;
axMap1.SendMouseDown = true;
axMap1.CursorMode = tkCursorMode.cmNone;
MapEvents.MouseDownEvent += AxMap1MouseDownEvent; // change MapEvents to axMap1
// <summary>
// Opens a marker from the file
// </summary>
private Image OpenMarker(string dataPath)
string path = Path.GetDirectoryName(Application.ExecutablePath) + @"..\..\..\..\icons\marker.png";
if (!File.Exists(path))
MessageBox.Show("Can't find the file: " + path);
Image img = new Image();
if (!img.Open(path, ImageType.USE_FILE_EXTENSION, true, null))
return img;
return null;
// <summary>
// Handles mouse down event and adds the marker
// </summary>
public void AxMap1MouseDownEvent(object sender, _DMapEvents_MouseDownEvent e)
if (e.button == 1) // left button
Shapefile sf = axMap1.get_Shapefile(m_layerHandle);
Shape shp = new Shape();
Point pnt = new Point();
double x = 0.0;
double y = 0.0;
axMap1.PixelToProj(e.x, e.y, ref x, ref y);
pnt.x = x;
pnt.y = y;
int index = shp.numPoints;
shp.InsertPoint(pnt, ref index);
index = sf.NumShapes;
if (!sf.EditInsertShape(shp, ref index))
MessageBox.Show("Failed to insert shape: " + sf.ErrorMsg[sf.LastErrorCode]);
The type of images supported by MapWinGIS.
Definition: Enumerations.cs:92
Sets drawing behaviour when overlapping labels and charts are present on map.
Definition: Enumerations.cs:282
The available types of point symbols.
Definition: Enumerations.cs:1143
The type of the shapefile.
Definition: Enumerations.cs:169
Available cursor modes. Determines the default respond of map to the action of user.
Definition: Enumerations.cs:344
Commonly used map projections to be set in Form Designer (see AxMap.Projection property).
Definition: Enumerations.cs:1741
Map component for visualization of vector, raster or grid data.
Definition: AxMap.cs:56
void Redraw()
Redraws all layers in the map if the map is not locked.
Definition: AxMap.cs:183
Represents an raster image of particular format which may be added to the map.
Definition: Image.cs:66
A point object represents a point with x, y, Z, and M values. Shapes created by adding point objects ...
Definition: PointClass.cs:38
double y
Gets or sets the y value of the point.
Definition: PointClass.cs:122
double x
Gets or sets the x value of the point.
Definition: PointClass.cs:113
Holds the set of options for visualization of shapefiles.
Definition: ShapeDrawingOptions.cs:239
Image Picture
Gets or sets the picture which will be used as texture brush (ShapeDrawingOptions....
Definition: ShapeDrawingOptions.cs:635
tkPointSymbolType PointType
Gets or sets the type of the point symbols.
Definition: ShapeDrawingOptions.cs:741
A shape object represents a geometric shape which can be added to a shapefile which is displayed in t...
Definition: Shape.cs:41
bool Create(ShpfileType shpType)
Creates a new shape of the specified type.
Definition: Shape.cs:154
bool InsertPoint(Point newPoint, ref int pointIndex)
Inserts the specified point object into the shape using the desired point index if possible.
Definition: Shape.cs:372
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
int NumShapes
Gets the number of shapes in the shapefile.
Definition: Shapefile.cs:254
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 Close()
Closes the image.
Definition: Image.cs:313
bool Open(string ImageFileName, ImageType fileType, bool InRam, ICallback cBack)
Opens an image from file.
Definition: Image.cs:357
void PixelToProj(double pixelX, double pixelY, ref double projX, ref double projY)
Converts pixel coordinates to projected map coordinates
Definition: AxMap.cs:2634
tkMapProjection Projection
Sets projection of the map. It providers 2 most commonly used coordinate system/projections to be eas...
Definition: AxMap.cs:2709
tkCursorMode CursorMode
Gets or sets the cursor mode for the map.
Definition: AxMap.cs:456
bool SendMouseDown
Gets or sets whether the map sends mouse down events.
Definition: AxMap.cs:553
int AddLayer(object Object, bool visible)
Adds a layer to the map.
Definition: AxMap.cs:1342
Shapefile get_Shapefile(int layerHandle)
Gets shapefile object associated with the layer.
Definition: AxMap.cs:1546
bool EditInsertShape(Shape shape, ref int shapeIndex)
Inserts a new shape in the shapefile.
Definition: Shapefile.cs:819