Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls smone help me!!!

i'm developed google map application and i assign an .. find longitude and latitude opperation to button click event.

so what happens is.. if someone input two cities as input to textboxes, this operation convert those cities to longitude and latitude values and store those values into label.

C#
protected void Button1_Click(object sender, EventArgs e)
    {
        
        String Strt_Address = TextBox1.Text;
        String End_Address = TextBox2.Text;

        string geocodeUrl1 = string.Format(@"http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", Strt_Address);

        string geocodeUrl2 = string.Format(@"http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", End_Address);


        XmlDocument geocodeXmlDoc1 = new XmlDocument();
        geocodeXmlDoc1.Load(geocodeUrl1);

        XmlDocument geocodeXmlDoc2 = new XmlDocument();
        geocodeXmlDoc2.Load(geocodeUrl2);

        XmlNamespaceManager XmlMngr1 = new XmlNamespaceManager(geocodeXmlDoc1.NameTable);
        XmlMngr1.AddNamespace("geo", @"http://www.w3.org/2003/01/geo/wgs84_pos#");

        XmlNamespaceManager XmlMngr2 = new XmlNamespaceManager(geocodeXmlDoc2.NameTable);
        XmlMngr2.AddNamespace("geo", @"http://www.w3.org/2003/01/geo/wgs84_pos#");


        string sLong1 = geocodeXmlDoc1.DocumentElement.SelectSingleNode(@"//geometry/location/lat", XmlMngr1).InnerText;
        string sLat1 = geocodeXmlDoc1.DocumentElement.SelectSingleNode(@"//geometry/location/lng", XmlMngr1).InnerText;

        string sLong2 = geocodeXmlDoc2.DocumentElement.SelectSingleNode(@"//geometry/location/lat", XmlMngr2).InnerText;
        string sLat2 = geocodeXmlDoc2.DocumentElement.SelectSingleNode(@"//geometry/location/lng", XmlMngr2).InnerText;

        Label1.Text = sLong1 + ", " + sLat1;
        Label2.Text = sLong2 + ", " + sLat2;

       

        Page.ClientScript.RegisterStartupScript(Page.GetType(), "script",
        "calcRoute()", true);
        // i'm calling my js function from here.......

    }

javascript call

so here i want assign it to two variable and according to those variable it will draw route.


JavaScript
function calcRoute() {
       // get the travelmode, startpoint and via point from the form
       var travelMode = $("#travelMode option:selected").text();

       var start = document.getElementById('<%= Label1.ClientID %>').value;
       var end = document.getElementById('<%= Label2.ClientID %>').value;



can you plsss soeone tell me how to pass label value to javascript variable... which i assigned in c#.......
Posted
Updated 27-Jun-13 19:21pm
v3
Comments
Sushil Mate 28-Jun-13 1:21am    
you been asking same questions here on google map. I will advise you to learn about the basics, Lets say C# , ASP.net & javascript. then try google or CP.

try :

Label1.Text.ClientId or Label1.Text
 
Share this answer
 
Below is the way you can use Label.Text in JavaScript
var start =<%=Label1.Text%>;
var end = <%=Label2.Text%>;
 
Share this answer
 

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