I want to input my lat and long but it has space in it so it won't accept the input.
The lat and long in my database is formatted in DMM (it's like this 41 24.2028, 2 10.4418)
I have tried removing the whitespaces but it leads me to different location
private void button1_Click(object sender, EventArgs e)
{
gMapControl1.DragButton = MouseButtons.Left;
gMapControl1.MapProvider = GMapProviders.GoogleMap;
lat = Convert.ToDouble(textBox1.Text);
longi = Convert.ToDouble(textBox2.Text);
gMapControl1.Position = new PointLatLng(lat, longi);
gMapControl1.MinZoom = 5;
gMapControl1.MaxZoom = 100;
gMapControl1.Zoom = 15;
PointLatLng point = new PointLatLng(lat, longi);
GMapMarker marker = new GMarkerGoogle(point, GMarkerGoogleType.red_small);
GMapOverlay markers = new GMapOverlay("markers");
markers.Markers.Add(marker);
gMapControl1.Overlays.Add(markers);
}
41 24.2028, 2 10.4418
from my understanding means 41 degree and 24.2028 minutes. This per se isn't a valid syntax, however you can easily split the degree- and the minutes-part:
var splitX = "41 24.2028".Split();
var degreeX = double.Parse(splitX[0]);
var minutesX = double.Parse(splitX[1]);
Finally you need to convert the minutes to decimal-degrees:
var resultX = degreeX + minutesX / 60;
So finally you get 41.40338.