Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
#region    fillCasemap Icon
private void fillCaseMap()
{
    try
    {
        Cursor.Current = Cursors.WaitCursor;
        //OpenStreetMap_Load();
        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 (dg_CaseDetails.Rows[0].Cells[0].Value.ToString().ToLower() == "1")
                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 != ""))
                {
                    //nd

                    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"];
               //Marker marker = new Marker(e.WorldLocation);

               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);
               //GPSpointShape = new PointShape(_log, _lat);

               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);

               MapXPos.Add(GPSpointShape.X);
               MapYPos.Add(GPSpointShape.Y);

               //000
               System.Drawing.Image img = null;
               if (MapFrom == 1)
               {
                   if (_Type1 == "L")
                   {
                       img = Properties.Resources.AQUA_GreenNew1;
                   }
                   else
                   {
                       // img = Properties.Resources.Aqua_RedNew1;

                       img = Properties.Resources.MapMarkerCCTV;

                       // img = Properties.Resources.MapMarkerCCTV_Loc;
                   }
               }
               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.MouseHover  += MapImage_SizeBig;
                   //marker.MouseLeave += MapImage_SizeSmall;
                   //marker.MouseClick -= MapImage_Click;
                   // marker.MouseClick += new EventHandler(MapImage_Click);
                   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);


                   // feature.ColumnValues.Add("ColummnName", _Type1 + _txtMap1 );

                   /////////////// 2nd Line Start
                   //TextStyle centerTopTextStyle2 = new TextStyle();
                   //centerTopTextStyle2.TextColumnName = "[ColummnName]";
                   //centerTopTextStyle2.Font = new GeoFont("Arial", 9, DrawingFontStyles.Regular);
                   //centerTopTextStyle2.PointPlacement = PointPlacement.UpperCenter;
                   //centerTopTextStyle2.YOffsetInPixel = -40;
                   //centerTopTextStyle2.XOffsetInPixel = 0;
                   //pointLayeraa2 = new InMemoryFeatureLayer();
                   //pointLayeraa2.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = centerTopTextStyle2;
                   //pointLayeraa2.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                   /////////////// 2nd Line End

                   //feature2.ColumnValues.Add("ColummnName", evN);
               }
               else
               {
                   feature.ColumnValues.Add("ColummnName", _txtMap1);
               }

               pointLayeraa.InternalFeatures.Add(feature);
               //pointLayeraa2.InternalFeatures.Add(feature2);

               MeetlayerOverlay.Layers.Add(pointLayeraa);
               //MeetlayerOverlay2.Layers.Add(pointLayeraa2);

               markerOverlay1.Markers.Add(marker);
               winformsMap1.Overlays.Add(MeetlayerOverlay);
               //winformsMap1.Overlays.Add(MeetlayerOverlay2);
               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
Posted
Comments
[no name] 5-Jan-24 15:01pm    
You have a particular "model" in mind that is not obvious to an outsider. You need to be more clear about what you want to do ... from a user point of view. You have a lot of detail that appears to have nothing in common with "maps" in general.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900