Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        B_Admin.CheckIsLogged();
        if (Gid < 1)
        {
            function.WriteErrMsg("请指定需要关联的景点");
        }
        DataTable modelDT = SqlHelper.JoinQuery("TOP 1 A.GeneralID,A.ItemID,A.Title,B.dtzb,B.Price", "ZL_CommonModel", "ZL_C_jdmx", "A.ItemID=B.ID", "A.GeneralID=" + Gid);

        if (modelDT.Rows.Count < 1 || string.IsNullOrEmpty(DataConvert.CStr(modelDT.Rows[0]["dtzb"])))
        {
            function.WriteErrMsg("请先为景点设定坐标数据");
        }

        double lng = 0; // 104.873626
        double lat = 0; // 26.587309

        if (!GetPointByStr(DataConvert.CStr(modelDT.Rows[0]["dtzb"]), out lng, out lat))
        {
            function.WriteErrMsg("景点坐标不正确");
        }
        string    nids   = "1";
        DataTable nodeDT = nodeBll.SelByPid(1, true);//景点的父节点为1

        foreach (DataRow dr in nodeDT.Rows)
        {
            nids += "," + dr["NodeID"];
        }
        //----------------------------------------------------------
        string where = "A.NodeID IN (" + nids + ")AND A.GeneralID!=" + Gid + " AND dtzb IS NOT NULL AND dtzb!=''";
        DataTable dt = SqlHelper.JoinQuery("A.GeneralID,A.ItemID,A.Title,B.dtzb,B.Price", "ZL_CommonModel", "ZL_C_jdmx", "A.ItemID=B.ID", where);

        dt.Columns.Add(new DataColumn("distance", typeof(double)));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow dr   = dt.Rows[i];
            string  json = dr["dtzb"].ToString();
            if (string.IsNullOrEmpty(json) || json.Equals("[]"))
            {
                continue;
            }
            double lng2, lat2;
            if (GetPointByStr(json, out lng2, out lat2))
            {
                dr["distance"] = BaiduMap.GetShortDistance(lng, lat, lng2, lat2);
            }
        }
        dt.Columns.Remove("dtzb");
        dt.DefaultView.Sort = "distance ASC";
        dt = dt.DefaultView.ToTable();
        DataTable result = dt.Clone();

        for (int i = 0; i < 50 && i < dt.Rows.Count; i++)
        {
            result.Rows.Add(dt.Rows[i].ItemArray);
        }
        //result.DefaultView.Sort = "distance ASC";
        RPT.DataSource = result;
        RPT.DataBind();
    }
Example #2
0
        /// <summary>
        /// POI 下载
        /// </summary>
        public void DownLoadPoi()
        {
            if (this.Extent == null)
            {
                Console.WriteLine(string.Format("{0}范围为空", this.City));
                return;
            }
            BaiduMap baiduMap  = new BaiduMap();
            var      dataTable = new DataTable();

            dataTable.Columns.Add("name", Type.GetType("System.String"));
            dataTable.Columns.Add("X", Type.GetType("System.String"));
            dataTable.Columns.Add("Y", Type.GetType("System.String"));
            dataTable.Columns.Add("r_addr", Type.GetType("System.String"));
            dataTable.Columns.Add("type", Type.GetType("System.String"));
            dataTable.Columns.Add("phone", Type.GetType("System.String"));
            baiduMap.downingPOIHandler += (poi, index, count) =>
            {
                DataRow row = dataTable.NewRow();
                row["name"]   = poi.name.Replace("'", " ");
                row["X"]      = poi.cx;
                row["Y"]      = poi.cy;
                row["r_addr"] = poi.address.Replace(",", "");
                row["type"]   = poi.type;
                row["phone"]  = poi.phone.Replace(",", ";");
                dataTable.Rows.Add(row);
            };
            baiduMap.downEndPOIHandler += message =>
            {
                var directory = this.GetCityDirectory();
                AsposeCellsHelper.ExportToExcel(dataTable, Path.Combine(directory, City + "_poi.xlsx"));
                dataTable.Rows.Clear();
            };
            baiduMap.getPOIByExtentKeyWords(this.Extent, string.Empty);
        }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //double distance = BaiduMap.GetShortDistance(121.467113, 37.480563, 121.467926, 37.480591);
        //function.WriteErrMsg(distance.ToString());
        double    lng    = 104.873626;
        double    lat    = 26.587309;//105.67933,26.02647
        string    nids   = "1";
        DataTable nodeDT = nodeBll.SelByPid(1, true);

        foreach (DataRow dr in nodeDT.Rows)
        {
            nids += "," + dr["NodeID"];
        }
        DataTable dt = SqlHelper.JoinQuery("A.GeneralID,A.ItemID,A.Title,B.dtzb,B.Price", "ZL_CommonModel", "ZL_C_jdmx", "A.ItemID=B.ID", "A.NodeID IN (" + nids + ") AND dtzb IS NOT NULL AND dtzb!=''");

        dt.Columns.Add(new DataColumn("distance", typeof(double)));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow dr   = dt.Rows[i];
            string  json = dr["dtzb"].ToString();
            if (string.IsNullOrEmpty(json) || json.Equals("[]"))
            {
                continue;
            }
            if (json.StartsWith("["))//完全地图
            {
                List <M_Map_Marker> list = JsonConvert.DeserializeObject <List <M_Map_Marker> >(json);
                if (list.Count < 1)
                {
                    continue;
                }
                //取第一坐标与其对比
                dr["distance"] = BaiduMap.GetShortDistance(lng, lat, Convert.ToDouble(list[0].mark.lng), Convert.ToDouble(list[0].mark.lat));
            }
            else
            {
                double lng2 = Convert.ToDouble(json.Split(',')[0]);
                double lat2 = Convert.ToDouble(json.Split(',')[1]);
                dr["distance"] = BaiduMap.GetShortDistance(lng, lat, lng2, lat2);
            }
        }
        dt.DefaultView.Sort = "distance ASC";
        DataTable result = dt.Clone();

        for (int i = 0; i < 50 && i < dt.Rows.Count; i++)
        {
            result.Rows.Add(dt.Rows[i].ItemArray);
        }
        //移除数据,避免json过大
        result.Columns.Remove("dtzb");
        RPT.DataSource = result;
        RPT.DataBind();
    }
Example #4
0
        private void InitView()
        {
            //设置标题栏

            var img_header_back = FindViewById <ImageView> (Resource.Id.img_header_back);

            img_header_back.Click += (sender, e) =>
            {
                this.Finish();
                OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
            };
            var bundle        = Intent.Extras;
            var alarmPosition = bundle.GetString("alarmPosition");

            if (!string.IsNullOrEmpty(alarmPosition) && alarmPosition.Contains(","))
            {
                var Positions = alarmPosition.Split(new char[] { ',' });
                nPosition = Convert.ToDouble(Positions [0].Substring(1));
                ePosition = Convert.ToDouble(Positions [1].Substring(1));
            }

            var tv_back = FindViewById <TextView> (Resource.Id.tv_back);

            tv_back.Text = "报警详细";
            var tv_desc = FindViewById <TextView> (Resource.Id.tv_desc);

            tv_desc.Text = "报警位置显示";

            mMapView      = FindViewById <MapView> (Resource.Id.bmap_view);
            bdMap         = mMapView.Map;
            bdMap.MapType = BaiduMap.MapTypeNormal;
            LatLng sourceLatLng = new LatLng(nPosition, ePosition);
            // 将GPS设备采集的原始GPS坐标转换成百度坐标
            CoordinateConverter converter = new CoordinateConverter();

            converter.From(Com.Baidu.Mapapi.Utils.CoordinateConverter.CoordType.Gps);
            // sourceLatLng待转换坐标
            converter.Coord(sourceLatLng);
            LatLng desLatLng = converter.Convert();
            //构建MarkerOption,用于在地图上添加Marker
            //构建Marker图标
            BitmapDescriptor bitmap = BitmapDescriptorFactory
                                      .FromResource(Resource.Drawable.ic_map);
            OverlayOptions option = new MarkerOptions().InvokePosition(desLatLng).InvokeIcon(bitmap).Draggable(true).InvokeZIndex(9);

            //在地图上添加Marker,并显示
            bdMap.AddOverlay(option);
            // 将地图移动到覆盖物位置
            MapStatusUpdate u = MapStatusUpdateFactory.NewLatLng(desLatLng);

            bdMap.SetMapStatus(u);
        }
Example #5
0
        /// <summary>
        /// 打开网点信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private static List <SiteInfo> OpenFile(String filePath)
        {
            DataTable       dt      = ExcelHelper.ExcelToDataTable("输入", true, filePath);
            List <SiteInfo> lstSite = ConvertHelper <SiteInfo> .ConvertToList(dt);

            foreach (var site in lstSite)
            {
                BaiduResult geocoder = JsonHelper.JsonDeserialize <BaiduResult>(BaiduMap.Geocoder(site.address));
                site.lat = geocoder.result.location.lat;
                site.lng = geocoder.result.location.lng;
            }
            return(lstSite);
        }
        private void DoSomething()
        {
            InitDataTable();
            if (this.extent == null)
            {
                return;
            }
            BaiduMap baidu = new BaiduMap();

            baidu.DowningEvent        += new DowningEventHandler(this.poiDownHandler);
            baidu.DownEndEvent        += new DownEndEventHandler(poiDownEndHandler);
            baidu.DowningMessageEvent += new DowningMessageHandler(poiDownMessageHandler);
            baidu.GetPoiByExtentKeyWords(this.extent, this.keyWords);
        }
Example #7
0
        public async void IpLocation()
        {
            var html = new TinyHttpClient().GetString("http://myip.ipip.net");
            var ip   = html?.Substring("IP:", " ");

            Assert.NotEmpty(ip);

            var map = new BaiduMap();
            var rs  = await map.IpLocationAsync(ip);

            Assert.NotNull(rs);

            var addrs = (rs["full_address"] + "").Split('|');

            Assert.Equal(7, addrs.Length);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <MyBaiduMap> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                mMapView = new MapView(Forms.Context, new BaiduMapOptions());

                mBaiduMap = mMapView.Map;
                this.SetNativeControl(mMapView);
                mBaiduMap.MyLocationEnabled = true;
                // 定位初始化
                mLocClient = new LocationClient(Forms.Context);
                mLocClient.RegisterLocationListener(this);
                LocationClientOption option = new LocationClientOption();
                option.OpenGps       = true;          // 打开gps
                option.CoorType      = "bd09ll";      // 设置坐标类型
                option.ScanSpan      = 1000;
                mLocClient.LocOption = option;
                mLocClient.Start();
            }
        }
Example #9
0
File: Program.cs Project: xchit/X
        static void Test2()
        {
            var addr = "容县容西镇移动营业厅";
            var city = "玉林";

            var bm = new BaiduMap();

            bm.Log = XTrace.Log;

            var gp = bm.GetGeoAsync(addr, city).Result;

            Console.WriteLine(gp);

            var geo = bm.GetGeoAsync(gp.Location).Result;

            Console.WriteLine(geo);

            //var org = bm.GetGeoAsync("新府中路1650号").Result;
            //var dst = bm.GetGeoAsync("广西容县高中").Result;
            //var dv = bm.GetDistanceAsync(org, dst).Result;
            //Console.WriteLine("{0}:\t{1}", dv.Distance, dv.Duration);

            var am = new AMap
            {
                Log = XTrace.Log
            };

            geo = am.GetGeoAsync(addr, city).Result;
            Console.WriteLine(geo);

            //var org2 = am.GetGeoAsync("新府中路1650号").Result;
            //var dst2 = am.GetGeoAsync("广西容县高中").Result;
            //dv = am.GetDistanceAsync(org2.Location, dst2.Location).Result;
            //Console.WriteLine("{0}:\t{1}", dv.Distance, dv.Duration);

            //var addrs = am.GetDistrictAsync("广西", 1, 450000).Result;
            //Console.WriteLine(addrs);
        }