Beispiel #1
0
        private void PageLoad()
        {
            if ((Request.QueryString["FromUserName"] != null || Session["FromUserName"] != null) && (Request.QueryString["ToUserName"] != null || Session["ToUserName"] != null))
            {
                string user  = Request.QueryString["FromUserName"] == null ? Session["FromUserName"].ToString() : Request.QueryString["FromUserName"].ToString();
                string user2 = Request.QueryString["ToUserName"] == null ? Session["ToUserName"].ToString() : Request.QueryString["ToUserName"].ToString();
                List <WXCUST_MSG_HIS> list = mss.GetWXCUST_MSG_HIS(string.Format(" Wxevent='location' AND FromUserName='******' ORDER BY id DESC ", user)); //获取用户最新地址
                if (list.Count == 0)                                                                                                                     //如果没有用户地址,则使用默认地址
                {
                    Response.Write(@"<script> var markerArr = [{ title: '没有你的坐标', content: '没有你的坐标', point: '121.459441|31.224461', isOpen: 0, icon: { w: 23, h: 25, l: 46, t: 21, x: 9, lb: 12} }
		 ];
        function createMap(){
        var map = new BMap.Map('dituContent');
        var point = new BMap.Point(121.488186,31.249162);
        map.centerAndZoom(point,13);
        window.map = map;
    }</script>");
                    Session["X"] = "121.459441";
                    Session["Y"] = "31.224461";
                }
                else
                {
                    Session["X"] = list[0].LOCATION_X;
                    Session["Y"] = list[0].LOCATION_Y;
                    string mp = @"<script> var markerArr = [{ 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);

                    WebClient client = new WebClient();
                    string    url2   = string.Format("http://api.map.baidu.com/geocoder/v2/?ak=42095ab67452cfefd9b5d3743d197f49&callback=renderReverse&location={0},{1}&output=json&pois=1", list[0].LOCATION_Y, list[0].LOCATION_X);// +list[0].Location_X + "," + list[0].Location_Y + "";  //根据用户坐标查找用户地址
                    client.Encoding = Encoding.UTF8;
                    string responseTest = client.DownloadString(url2);

                    foreach (ListItem l in DropDownList1.Items)
                    {
                        if (responseTest.Contains(l.Text))
                        {
                            DropDownList1.SelectedValue = l.Text;   //显示用户所在城市门店
                        }
                    }
                    //DropDownList1_SelectedIndexChanged(null, null);
                }
            }
            else
            {
                Response.Write(@"<script> var markerArr = [{ title: '没有你的坐标', content: '没有你的坐标', point: '121.459441|31.224461', isOpen: 0, icon: { w: 23, h: 25, l: 46, t: 21, x: 9, lb: 12} }
		 ];
function createMap(){
        var map = new BMap.Map('dituContent');//在百度地图容器中创建一个地图
        var point = new BMap.Point(121.488186,31.249162);//定义一个中心点坐标
        map.centerAndZoom(point,13);//设定地图的中心点和坐标并将地图显示在地图容器中
        window.map = map;//将map变量存储在全局
    }</script>");
            }
            DropDownList1_SelectedIndexChanged(null, null);
        }