根据搜索需求在谷歌地图上显示数据? [英] showing data on google map as per searching needs?

查看:101
本文介绍了根据搜索需求在谷歌地图上显示数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个谷歌地图项目,它在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(); < br $>
}

其他

{

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();
}
}
}
}

}


这篇关于根据搜索需求在谷歌地图上显示数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆