根据搜索需求在谷歌地图上显示数据?
问题描述:
我有一个谷歌地图项目,它在evnet数据库中显示地图上的每个添加的事件,但我需要在用户按照Chif来宾或国家或类别过滤它时显示事件....... plz帮助我???
I have a google map project which is showing every added Event on the map in the evnet database but i need to show the events when users filter it by the Chif guest or country or by category.......plz help me???
答
使用System;
使用System.Collections.Generic;
使用System .Data;
使用System.Data.SqlClient;
使用ClassLibrary1;
public partial class _Default:System.Web.UI.Page
{Class1 cl = new Class1();
protected void Page_Load(object sender,EventArgs e)
$
//此方法用于将数据表转换为json字符串
public string ConvertDataTabletoString( )
{
DataTable dt = new DataTable();
using(SqlConnection con = new SqlConnection(Data Source = arsalan\\\ \\ sqlexpress; Initial Catalog = FindEvent; Integrated Securi ty = true))
{
使用(SqlCommand cmd = new SqlCommand(select lat = latitude,lng = longitude,ename = eventName,chiefguest fron Event, con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd) ;
da.Fill(dt);
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script。 Serialization.JavaScriptSerializer();
List< dictionary>< string,>> rows = new List< dictionary>< string,>>();
Dictionary< string,>行;
foreach(dt.Rows中的DataRow dr)
{
row = new Dictionary< string,>();
foreach(DataColumn col in dt.Columns)
{
row.Add(col.ColumnName,dr [col]);
}
rows.Add(row);
}
返回serializer.Serialize(rows);
}
}
}
protected void Button3_Click(object sender,EventArgs e)
{
if(DropDownList6.SelectedItem.Text ==By Country)
{
DropDownList3.DataSource = cl.showCountry();
DropDownList3.DataValueField =C_ID;
DropDownList3.DataTextField =C_Name;
DropDownList3.DataBind();
}
else if(DropDownList6.SelectedItem.Text ==按类别)
{
DropDownList3.DataSource = cl.showcategory ();
DropDownList3.DataValueField =C_ID;
DropDownList3.DataTextField =C_Name;
DropDownList3.DataBind();
}
其他
{
DropDownList3.DataSource = cl.showarea();
DropDownList3.DataValueField =A_ID;
DropDownList3.DataTextField =A_Name;
DropDownList3.DataBind();
}
}
protected void Button4_Click(object sender,EventArgs e)
{
{
if(DropDownList6.SelectedItem.Text ==By Country)
{
GridView1.DataSource = cl.countryID(Convert.ToInt16( DropDownList3.SelectedValue));
GridView1.DataBind();
}
else if(DropDownList6.SelectedItem.Text ==按类别)
{
GridView1.DataSource = cl.categoryID(Convert.ToInt16(DropDownList3.SelectedValue));
GridView1.DataBind() ;
}
其他
{
GridView1.DataSource = cl.areaID(Convert.ToInt16(DropDownList3。 SelectedValue));
GridView1.DataBind();
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using ClassLibrary1;
public partial class _Default : System.Web.UI.Page
{Class1 cl=new Class1();
protected void Page_Load(object sender, EventArgs e)
{
}
// This method is used to convert datatable to json string
public string ConvertDataTabletoString()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection("Data Source=arsalan\\sqlexpress;Initial Catalog=FindEvent;Integrated Security=true"))
{
using (SqlCommand cmd = new SqlCommand("select lat=latitude,lng=longitude,ename=eventName,chiefguest fron Event", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<dictionary><string,>> rows = new List<dictionary><string,>>();
Dictionary<string,> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string,>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
return serializer.Serialize(rows);
}
}
}
protected void Button3_Click(object sender, EventArgs e)
{
if (DropDownList6.SelectedItem.Text == "By Country")
{
DropDownList3.DataSource = cl.showCountry();
DropDownList3.DataValueField = "C_ID";
DropDownList3.DataTextField = "C_Name";
DropDownList3.DataBind();
}
else if (DropDownList6.SelectedItem.Text == "By Category")
{
DropDownList3.DataSource = cl.showcategory();
DropDownList3.DataValueField = "C_ID";
DropDownList3.DataTextField = "C_Name";
DropDownList3.DataBind();
}
else
{
DropDownList3.DataSource = cl.showarea();
DropDownList3.DataValueField = "A_ID";
DropDownList3.DataTextField = "A_Name";
DropDownList3.DataBind();
}
}
protected void Button4_Click(object sender, EventArgs e)
{
{
if (DropDownList6.SelectedItem.Text == "By Country")
{
GridView1.DataSource = cl.countryID(Convert.ToInt16(DropDownList3.SelectedValue));
GridView1.DataBind();
}
else if (DropDownList6.SelectedItem.Text == "By Category")
{
GridView1.DataSource = cl.categoryID(Convert.ToInt16(DropDownList3.SelectedValue));
GridView1.DataBind();
}
else
{
GridView1.DataSource = cl.areaID(Convert.ToInt16(DropDownList3.SelectedValue));
GridView1.DataBind();
}
}
}
}
}