public void MarkPoints(AxMap axMap1, string dataPath)
{
//axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
string filename = dataPath;
if (!File.Exists(filename))
{
MessageBox.Show("Couldn't file the file: " + filename);
return;
}
var sf = new Shapefile();
sf.Open(filename, null); // open shape file
m_layerHandle = axMap1.AddLayer(sf, true); // add layer to the map
sf = axMap1.get_Shapefile(m_layerHandle); // Gets shapefile object associated with the layer. // 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]);
return;
}
m_layerHandle = axMap1.AddLayer(sf, true);
ShapeDrawingOptions options = sf.DefaultDrawingOptions;
options.PointType = tkPointSymbolType.ptSymbolPicture;
options.Picture = this.OpenMarker(dataPath);
sf.CollisionMode = tkCollisionMode.AllowCollisions;
PutMarker();
//axMap1.SendMouseDown = true;
//axMap1.CursorMode = tkCursorMode.cmNone;
//axMap1.MouseDownEvent += AxMap1MouseDownEvent; // change MapEvents to axMap1
axMap1.SendMouseMove = true;
axMap1.CursorMode = tkCursorMode.cmIdentify;
axMap1.ShapeHighlighted += ClickMarker;
}
public void ClickMarker(object sender, _DMapEvents_ShapeHighlightedEvent e)
{
Console.WriteLine("Salom");
Shapefile sf = axMap1.get_Shapefile(m_layerHandle);
if (sf != null)
{
string s = "";
for (int i = 0; i < sf.NumFields; i++)
{
string val = sf.get_CellValue(i, e.shapeIndex).ToString();
if (val == "") val = "null";
s += sf.Table.Field[i].Name + ":" + val + "; ";
}
Console.WriteLine(s);
}
}
I am making clickable marker. This is the my code above. I am following this script in documentation.
When I run the program and click over the marker, it shows this exception error:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.