2

I am trying to import a file with a list of latitude and longitude coordinates. In Visual C#, and using GMAP.NET, a marker is placed for every coordinate pair. I want multiple files to be able to be uploaded, and for the user to be able to select the color of the marker for that specific file. I have a combobox with a few options included, however when I try to set the color of the marker to the text in the textbox, it can't "implicitly convert type string to GMarkerGoogleType". Is there a way to make this conversion?

Here is the relevant code:

private void btn_KMLFile_Click(object sender, EventArgs e)
    {
        DialogResult result = openFileDialog4.ShowDialog();
        if (result == DialogResult.OK)
        {
            string filename = openFileDialog4.FileName;
            string[] lines = System.IO.File.ReadAllLines(filename);
            foreach (string line in lines)
            {
                GMarkerGoogleType MarkerColor = cbo_MarkerType.Text;  //How can I convert this string to a GMarkerGoogleType?
                string[] Data_Array = line.Split(',');
                Double londecimal = Convert.ToDouble(Data_Array[0]);
                Double latdecimal = Convert.ToDouble(Data_Array[1]);
                var marker3 = new GMarkerGoogle(new PointLatLng(latdecimal, londecimal), MarkerColor);
                marker3.IsVisible = true;
                gMapOverlay.Markers.Add(marker3);

                gmap.Update();


            }
        }
    }

EDIT: This question is not a duplicate, the question can be rephrased as what type is a GMarkerGoogleType?

manateejoe
  • 344
  • 2
  • 6
  • 19
  • Have a look at the enum's definition in the [source code](https://greatmaps.codeplex.com/SourceControl/latest#GMap.NET.WindowsForms/GMap.NET.WindowsForms/Markers/GMarkerGoogle.cs) – rdoubleui Jul 16 '15 at 08:18

1 Answers1

0

GMarkerGoogleType is an enum, so you're basically asking for a conversion from string to GMarkerGoogleType:

GMarkerGoogleType MarkerColor = (GMarkerGoogleType)Enum.Parse(typeof(GMarkerGoogleType), cbo_MarkerType.Text, true);
rdoubleui
  • 3,554
  • 4
  • 30
  • 51
  • when I try this I get the following error: Must specify valid information for parsing in the string. How do I correct this? EDIT: Figured it out, it was in another part of the code, Thanks for the help! – manateejoe Jul 13 '15 at 14:20