#region fillCasemap Icon
private void fillCaseMap()
{
try
{
Cursor.Current = Cursors.WaitCursor;
Clear_Map_Layers();
string _lat = "", _long = "", _latC = "", _longC = "", _tool = "", _txtMap = "";
MapXPos.Clear();
MapYPos.Clear();
EventLatLong.Clear();
for (int i = 10; i < dg_CaseDetails.Columns.Count; i++)
{
_lat = _long = _latC = _longC = _tool = _txtMap = "";
for (int j = 0; j < dg_CaseDetails.Rows.Count; j++)
{
if (j == 0)
{
_tool = "Event " + dg_CaseDetails.Rows[j].Cells[i].Value.ToString().Trim().ToLower().Replace("event", "").Replace(" ", "");
_txtMap = "/E-" + dg_CaseDetails.Rows[j].Cells[i].Value.ToString().Trim().ToLower().Replace("event", "").Replace(" ", "");
}
if ((dg_CaseDetails.Rows[j].Cells[1].Value.ToString().ToLower() == "latitude") && (dg_CaseDetails.Rows[j].Cells[i].Value != null))
{
_Map = "L";
_lat = dg_CaseDetails.Rows[j].Cells[i].Value.ToString().ToLower();
}
if ((dg_CaseDetails.Rows[j].Cells[1].Value.ToString().ToLower() == "longitude") && (dg_CaseDetails.Rows[j].Cells[i].Value != null))
{
_Map = "L";
_long = dg_CaseDetails.Rows[j].Cells[i].Value.ToString().ToLower();
}
if ((dg_CaseDetails.Rows[j].Cells[1].Value.ToString().ToLower().Replace(" ", "") == "cctvlocation") && (dg_CaseDetails.Rows[j].Cells[i].Value != null))
{
string[] Latt = dg_CaseDetails.Rows[j].Cells[i].Value.ToString().ToLower().Trim().Split(',');
_Map = "C";
_latC = Latt[0];
_longC = Latt[1];
}
if ((_lat != "") && (_long != ""))
{
DrawBallonOnMapLoc(_lat, _long, _tool, _txtMap, _Map, 1, 0);
EventLatLong.Add(_lat + "|" + _long + "|" + _tool + "|" + _txtMap + "|" + _Map + "|" + LatLongXY);
_lat = "";
_long = "";
}
if ((_latC != "") && (_longC != ""))
{
DrawBallonOnMapLoc(_latC, _longC, _tool, _txtMap, _Map, 1, 0);
EventLatLong.Add(_latC + "|" + _longC + "|" + _tool + "|" + _txtMap + "|" + _Map + "|" + LatLongXY);
_latC = "";
_longC = "";
}
}
}
double minx = 0, maxy = 0, maxx = 0, miny = 0;
if (MapXPos.Count > 0)
{
minx = MapXPos.Min();
maxx = MapXPos.Max();
miny = MapYPos.Min();
maxy = MapYPos.Max();
winformsMap1.CurrentExtent = new RectangleShape(minx, maxy, maxx, miny);
winformsMap1.Refresh();
}
Cursor.Current = Cursors.Default;
}
catch (Exception ee)
{ Cursor.Current = Cursors.Default; }
}
#endregion
What I have tried:
in this i have done it in a simple way where i can get the value of lat and long along with the value of cctvlocation if the value of both these are as same then it comes out with the result when iclick on lat and long column it shows the icon of the place based on lat and long .when clicked on cctv loaction it shows the icon of the same aswell. but if the position of both are completely same then it shows both the icon based on the column i click .i want it to get corrected in a way if both are completely ame then a new icon should be there instead of the old one .how can i achieve it .
public void DrawBallonOnMapLoc(string _lat1, string _log1, string _toolTip, string _txtMap1, string _Type1, int MapFrom, int ImgID)
{
try
{
double _log = Convert.ToDouble(_log1);
double _lat = Convert.ToDouble(_lat1);
markerOverlay1.MapControl = winformsMap1;
if (winformsMap1.Overlays.Contains("MarkerOverlay"))
{ }
else
{
winformsMap1.Overlays.Add("MarkerOverlay", markerOverlay1);
}
winformsMap1.Refresh();
markerOverlay1 = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"];
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
proj4.Open();
Vertex GPSvertex_SphericalMercator = proj4.ConvertToExternalProjection(_log, _lat);
proj4.Close();
PointShape GPSpointShape = null;
GPSpointShape = new PointShape(GPSvertex_SphericalMercator);
Marker marker = new Marker(GPSpointShape);
Feature feature = new Feature(GPSpointShape.X, GPSpointShape.Y);
Feature feature2 = new Feature(GPSpointShape.X, GPSpointShape.Y);
LatLongXY = GPSpointShape.X.ToString() + "|" + GPSpointShape.Y.ToString();
MapXPos.Add(GPSpointShape.X);
MapYPos.Add(GPSpointShape.Y);
System.Drawing.Image img = null;
if (MapFrom == 1)
{
if (_Type1 == "L")
{
img = Properties.Resources.AQUA_GreenNew1;
}
else
{
img = Properties.Resources.MapMarkerCCTV;
}
}
else if (MapFrom == 2)
{
string destFile0 = System.IO.Path.Combine(Value.ValueG._DataFilePath + @"\Photo\", System.IO.Path.GetFileName(_Type1));
img = System.Drawing.Image.FromFile(destFile0);
marker.Name = ImgID.ToString() + "|" + _txtMap1;
marker.Click += new EventHandler(MapImage_Click);
marker.Cursor = Cursors.Hand;
}
Bitmap item = new Bitmap(img, new System.Drawing.Size(23, 34));
marker.Image = item;
marker.ToolTipText = _toolTip;
marker.Width = 23;
marker.Height = 34;
marker.YOffset = -30;
marker.XOffset = -10;
TextStyle centerTopTextStyle = new TextStyle();
centerTopTextStyle.TextColumnName = "[ColummnName]";
if (MapFrom == 1)
{
if (_Type1 == "L")
{
centerTopTextStyle.TextSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.DarkGreen);
}
else
{
centerTopTextStyle.TextSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.DarkRed);
}
}
else
{
centerTopTextStyle.TextSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.DarkGreen);
}
centerTopTextStyle.Font = new GeoFont("Arial", 9, DrawingFontStyles.Regular);
centerTopTextStyle.PointPlacement = PointPlacement.UpperCenter;
centerTopTextStyle.YOffsetInPixel = -20;
centerTopTextStyle.XOffsetInPixel = 0;
InMemoryFeatureLayer pointLayeraa = new InMemoryFeatureLayer();
pointLayeraa.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = centerTopTextStyle;
pointLayeraa.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
InMemoryFeatureLayer pointLayeraa2 = new InMemoryFeatureLayer();
if (MapFrom == 1)
{
string ev = _toolTip.ToLower().Replace("event", "").Replace(" ", "");
string evN = bfc.fill_sigle_value("select fieldvalue from Case_FindingDetail where case_id='" + Value.ValueG._caseID + "' and FieldID = 2 and CaseFind_Id=" + ev);
if (evN != "")
{
evN = " : " + evN;
}
feature.ColumnValues.Add("ColummnName", _Type1 + _txtMap1 + evN);
}
else
{
feature.ColumnValues.Add("ColummnName", _txtMap1);
}
pointLayeraa.InternalFeatures.Add(feature);
MeetlayerOverlay.Layers.Add(pointLayeraa);
markerOverlay1.Markers.Add(marker);
winformsMap1.Overlays.Add(MeetlayerOverlay);
winformsMap1.CenterAt(feature);
winformsMap1.Refresh();
ZoomLevelCheck();
}
catch (System.NullReferenceException)
{
}
catch (Exception ex1)
{
}
}
this is the code of the
DrawBallonOnMapLoc
method .help me if anyone know it