Start New Discussion within our Software Development Community

Hi Guys,
i am making an application which can take longitude and latitude as input from user and will locate the respective point on google map using default web browser i am able to open a browser through this

private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.gorissen.info/Pierre/maps/googleMapLocation.php");
        }

this will open google map with two text boxes where we can enter longitude and latitude of a location
but i don't know how to transfer that user input in these text boxes can any one solve and explain this
Regards

how to transfer that user input in these text boxes

Pass them in the URL.

Here's a simple code with a nice Finnish twist

double latitude = 0; // textBox1.Text
double longitude = 0; // textBox2.Text
string strURL = "";
bool isValidCoordinate = false; // use a flag to indicate valid values for lat and lon

if(double.TryParse(textBox1.Text, out latitude))
{
    // check that lat is between correct values
    isValidCoordinate = true;
}
else
{
    isValidCoordinate = false;
}
if(isValidCoordinate && double.TryParse(textBox2.Text, out longitude))
{
    // check that lon is between correct values
}
else
{
    isValidCoordinate = false;
}
if(isValidCoordinate)
{
    // We have valid coordinates, show the map
    strURL = @"http://www.gorissen.info/Pierre/maps/googleMapLocation.php?";
    strURL += "lat=" + latitude.ToString(); // add latitude
    strURL +=  @"&lon=" + longitude.ToString(); // add longitude
    strURL += @"&setLatLon=Set";
    // Here in Finland we use comma instead of dot, so I have to do this little fix :)
    strURL = strURL.Replace(",", ".");
    // Now the url is ready, display it
    System.Diagnostics.Process.Start(strURL);
}

You should add sanity check for lat and lon values after they are parsed from the textboxes.

HTH

This question has already been answered. Start a new discussion instead.