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"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)