How to get Distance in one click

Mar 16, 2010 at 8:27 AM

I would like to get the distance in Kilometers in one click - right now it only works with 2 button clicks.

Button 3_click does not show kilometers, it only draws the map. Am i missing an update or something?

this is working fine, when i press button 1, it shows the route on map, and when i press button 2 it shows kilometers in km.Text:

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

protected {

</font></font><font size="2" color="#0000ff">

 

</font>

void Button1_Click(object sender, EventArgs e)

 

query = "from: Paris to: Berlin";
        GoogleMap1.Directions.Clear();
        GoogleMap1.Directions.Add(new GoogleDirection(query, "route", "europe"));
}

 

    protected void Button2_Click(object sender, EventArgs e)
    {
        if (GoogleMap1.Directions.Count > 0)
        {
            GoogleDirection dir = GoogleMap1.Directions[0];
            //km.Text = string.Format(dir.Distance.Meters);
            km.Text = string.Format("{0}", dir.Distance.Meters / 1000);
        }

    }

 

protected {void Button3_Click(object sender, EventArgs e)

 query = "from: Paris to: Berlin";
        GoogleMap1.Directions.Clear();
        GoogleMap1.Directions.Add(new GoogleDirection(query, "route", "europe"));
        if (GoogleMap1.Directions.Count > 0)
        {
            GoogleDirection dir = GoogleMap1.Directions[0];
            //km.Text = string.Format(dir.Distance.Meters);
            km.Text = string.Format("{0}", dir.Distance.Meters / 1000);
        }

}