因为爱GIS,我们聚集于此
  • 快捷登录:

supermap iClient for silverlight 根据坐标点 绘制图形

2014-11-27 20:18| 发布者: 咱是专业的| 查看: 2626| 评论: 0

摘要: /// summary /// 坐标范围定位 /// /summary /// param name=coords/param public void ZoomTo(string coords) { featuresLayer.Features.Clear(); ...
        /// <summary>
        /// 坐标范围定位
        /// </summary>
        /// <param name="coords"></param>
        public void ZoomTo(string coords)
        {
            featuresLayer.Features.Clear();
            string[] coordArr = coords.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

            GeoRegion region = new GeoRegion();
            ObservableCollection<Point2DCollection> parts = new ObservableCollection<Point2DCollection>();
            Point2DCollection ptnColl = new Point2DCollection();
            Feature feature = new Feature();

                foreach (string str in coordArr)
                {
                    string tempCoord = str.Substring(1, str.Length - 2);  //取出 1122.23232,773.211212

                    string[] tempPtn = tempCoord.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                    Point2D pnt = new Point2D(Convert.ToDouble(tempPtn[0]), Convert.ToDouble(tempPtn[1]));


                    ptnColl.Add(pnt);

                }
                if (ptnColl.Count < 3)  //如果是矩形
                {
                    Point2D ptn1 = new Point2D(ptnColl[0].X, ptnColl[0].Y);
                    Point2D ptn2= new Point2D(ptnColl[1].X, ptnColl[0].Y);
                    Point2D ptn3 = new Point2D(ptnColl[0].X, ptnColl[1].Y);
                    Point2D ptn4 = new Point2D(ptnColl[1].X, ptnColl[1].Y);

                    ptnColl.Clear();

                    ptnColl.Add(ptn1);
                    ptnColl.Add(ptn2);
                    ptnColl.Add(ptn4);
                    ptnColl.Add(ptn3);
                    ptnColl.Add(ptn1);

                }
            
                    parts.Add(ptnColl);
                    region.Parts = parts;

                    feature.Geometry = region;

                    feature.Style = myCustomFillStyle;
                           
   
            featuresLayer.Features.Add(feature);

            MyMap.ZoomTo(feature.Geometry.Bounds);
        }
坐标点的组织形式 “(124.23212,121243.2121);(983.423,412.4232);(141.23212,1443.2121);(983.423,4124.098)”
 

鲜花

握手

雷人

路过

鸡蛋
相关推荐

最新评论

相关推荐
关闭

热门推荐上一条 /1 下一条

© 2013-2014 GIS520 ( 陕ICP备14003560号-1 )Powered by Discuz! X3.2 Template by giscafer   
返回顶部