protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { string Province = ""; if (DropDownList1.SelectedValue != "请选择省份") { Province = " and Province='" + DropDownList1.SelectedValue + "' "; } List <MDSearch> list = null; if (DropDownList2.SelectedValue != "请选择城市") { list = mss.GetModelList("Phone<>'' and X<>'0' and Name not like '%已撤柜%' and StoreType = '" + DropDownList4.SelectedValue + "' and City='" + DropDownList2.SelectedValue + "' " + Province + " order by dbo.jl(" + Session["X"].ToString() + "," + Session["Y"].ToString() + ",x,y)"); } else { list = mss.GetModelList(" 1=1 and Phone<>'' and X<>'0' and StoreType = '" + DropDownList4.SelectedValue + "' and Name not like '%已撤柜%' " + Province + " order by dbo.jl(" + Session["X"].ToString() + "," + Session["Y"].ToString() + ",x,y)"); } if (DropDownList4.SelectedValue == "1") { se.InnerHtml = @"<ul> "; string mp = @"<script> var markerArr = ["; mp = mp.Replace("{0}", Session["X"].ToString()).Replace("{1}", Session["Y"].ToString()); foreach (MDSearch m in list) { double a = Distance(double.Parse(m.X.ToString()), double.Parse(m.Y.ToString()), double.Parse(Session["X"].ToString()), double.Parse(Session["Y"].ToString())); //DropDownList2.Items.Add(new ListItem(m.Name, m.X + "," + m.Y)); se.InnerHtml += string.Format(@"<li> <p> <b>{2}</b></p> <p>{3}</p> <p><span><a href='http://api.map.baidu.com/place/search?query={4}&location={0},{1}&radius=1000®ion={5}&output=html&src=yourCompanyName|yourAppName'>查看地图</a></span><strong style='font-size:12px;'>{6}</strong><div class='nordiv'>品牌经营:{7}</div></p> </li>", Session["X"].ToString(), Session["Y"].ToString(), m.Name + "(约" + Math.Round(a / 1000, 2).ToString() + "公里)", m.Address, m.Address, DropDownList1.SelectedValue, m.Phone, m.PP); mp += "{ title: '{0}', content: '{0}', point: '{1}|{2}', isOpen: 0, icon: { w: 23, h: 25, l: 46, t: 21, x: 9, lb: 12} } ,"; mp = mp.Replace("{0}", m.Name).Replace("{1}", m.X.ToString()).Replace("{2}", m.Y.ToString()); } se.InnerHtml += " </ul> <br />"; mp += @"{ title: '你的位置', content: '你的位置', point: '{0}|{1}', isOpen: 0, icon: {w:23,h:25,l:23,t:21,x:9,lb:12} } ]; function createMap() { var map = new BMap.Map('dituContent'); var point = new BMap.Point({0},{1}); map.centerAndZoom(point, 13); window.map = map; }</script>"; mp = mp.Replace("{0}", Session["X"].ToString()).Replace("{1}", Session["Y"].ToString()); Response.Write(mp); } else { se.InnerHtml = @"<ul> "; string mp = @"<script> var markerArr = ["; mp = mp.Replace("{0}", Session["X"].ToString()).Replace("{1}", Session["Y"].ToString()); foreach (MDSearch m in list) { double a = Distance(double.Parse(m.X.ToString()), double.Parse(m.Y.ToString()), double.Parse(Session["X"].ToString()), double.Parse(Session["Y"].ToString())); //DropDownList2.Items.Add(new ListItem(m.Name, m.X + "," + m.Y)); se.InnerHtml += string.Format(@"<li> <p> <b>{2}</b></p> <p>{3}</p> <p><span><a href='http://api.map.baidu.com/place/search?query={4}&location={0},{1}&radius=1000®ion={5}&output=html&src=yourCompanyName|yourAppName'>查看地图</a></span><strong style='font-size:12px;'>{6}</strong></p> </li>", Session["X"].ToString(), Session["Y"].ToString(), m.Name + "(约" + Math.Round(a / 1000, 2).ToString() + "公里)", m.Address, m.Address, DropDownList1.SelectedValue, m.Phone); mp += "{ title: '{0}', content: '{0}', point: '{1}|{2}', isOpen: 0, icon: { w: 23, h: 25, l: 46, t: 21, x: 9, lb: 12} } ,"; mp = mp.Replace("{0}", m.Name).Replace("{1}", m.X.ToString()).Replace("{2}", m.Y.ToString()); } se.InnerHtml += " </ul> <br />"; mp += @"{ title: '你的位置', content: '你的位置', point: '{0}|{1}', isOpen: 0, icon: {w:23,h:25,l:23,t:21,x:9,lb:12} } ]; function createMap() { var map = new BMap.Map('dituContent'); var point = new BMap.Point({0},{1}); map.centerAndZoom(point, 13); window.map = map; }</script>"; mp = mp.Replace("{0}", Session["X"].ToString()).Replace("{1}", Session["Y"].ToString()); Response.Write(mp); } }