Click here to Skip to main content
16,022,060 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi dear friends....
I am using google map in my project and i have two text box one is for latitude and the other is for longitude when I search any area from map it gives me accurate result and in map i am also using draggable marker so that I can change location from map and when I enter any location or address than it gives me result and when I change the address by draggable marker and want to store the new result(after changing position of draggable marker)but it stores previous result from the text box(before changing position of draggable marker).
below is my code

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using System.Xml;
using System.Xml.XPath;

namespace OnlinePropertyDealer
{
    public partial class selectFromMap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
          
            if (!IsPostBack)
            {
                try
                {
                    hdn_F.Value = Server.HtmlEncode(Request.Cookies["dealer_id"].Value);

                    OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["conStr"].ToString());

                    con.Open();
                    string query = "select a.late,a.longe from area_table a, dealer_table d where a.area_id=d.area_id and d.dealer_id='" + hdn_F.Value + "'";
                    OracleCommand cmd = new OracleCommand(query, con);
                    OracleDataReader re = cmd.ExecuteReader();
                    while (re.Read())
                    {
                        txtLat.Text = re[0].ToString();
                        txtLng.Text = re[1].ToString();

                    }
                }
                catch
                {
                    Page.Response.Redirect("dealerAds.aspx");
                }
                finally { }
            }
        }

        
                     
        

        protected void Button2_Click(object sender, EventArgs e)
        {
            GetLongitudeAndLatitude(Txtcity.Text, "false");

        }

        public string GetLongitudeAndLatitude(string address, string sensor)
        {
            string urlAddress = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + HttpUtility.UrlEncode(address) + "&sensor=" + sensor;
            string returnValue = "";
            string returnValue2 = "";
            try
            {
                XmlDocument objXmlDocument = new XmlDocument();
                objXmlDocument.Load(urlAddress);
                XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/GeocodeResponse/result/geometry/location");
                foreach (XmlNode objXmlNode in objXmlNodeList)
                {
                    // GET LONGITUDE 
                    returnValue = objXmlNode.ChildNodes.Item(0).InnerText;
                    txtLat.Text = returnValue;

                    // GET LATITUDE 
                    returnValue2 = objXmlNode.ChildNodes.Item(1).InnerText;
                    txtLng.Text = returnValue2;
                }
            }
            catch
            {
            }
            return returnValue;

        }

       
        protected void Button1_Click1(object sender, EventArgs e)
        {
           
            Response.Cookies["lat"].Value = txtLat.Text;
            Response.Cookies["lng"].Value = txtLng.Text;
            Response.Cookies["address"].Value = Txtcity.Text;
            Response.Cookies["AreaId"].Value = ddArea.SelectedValue;

            Page.Response.Redirect("PostAd.aspx");
        }

       

    }
}
Posted
Updated 29-Aug-14 1:12am
v2
Comments
ZurdoDev 28-Aug-14 14:21pm    
You should be able to debug and see what is happening.

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